sách gpt4 ai đã đi

javascript - Breeze 底层数组在保存时出现 null 错误

In lại 作者:行者123 更新时间:2023-12-03 10:16:17 31 4
mua khóa gpt4 Nike

当我想要保存我创建的实体时,收到“500(内部服务器错误)底层错误为空”错误消息。

Kịch bản:

  • 用户打开一个模式窗口,可以在其中创建/编辑博客条目
  • 他可以选择标签
  • 他还可以创建新标签
  • 如果存在尚不存在的标签,系统会自动创建它

当系统想要保存新标签时会发生错误。我真正不明白的是哪个数组为空?!如果我写出新创建的实体,那么我会看到一个由 Breeze 创建的健康实体,并且没有空值,除了一个(博客描述字段,但它不是必填字段)

我做了什么来定位缺陷:

  • 仔细检查代码 - 完成
  • 检查缓存 - 已完成 - 已禁用
  • 谷歌搜索 - 完成 - 看来这是一个非常罕见的问题
  • 将代码放入 Controller 中,无论是否是范围问题 - 完成 - 结果是相同的
  • 检查 REST Controller ,上次更改是在 71 天前,但在其他情况下运行良好
  • sleep ...有时会有所帮助 - 完成,很棒,但没有帮助
  • 重新启动机器 - 完成 - 没有任何反应
  • 我想我已经没有主意了......

这是代码。里面没有什么新东西。这样的代码在应用程序的其他地方工作没有任何问题。

该函数由 ngTags-input stuff 的 onTagAdding 方法调用,并将其放置在服务中。

function onTagAdding(tag)
{
console.log("ontagadding");
var select = 'id, name';
var p = new Predicate('name', FilterQueryOp.Equals, tag.name);

datacontext.tag.getAll(select, p).then(function (result)
{
if (result.length < 1)
{
//add new tag
var newTag = datacontext.tag.create();
newTag.name = tag.name;
console.log('tag ontagadding', tag);
console.log('newTag ontagadding', newTag);
}

datacontext.save().then(function (saveResult)
{
console.log('saved tag ontagadding');
if (typeof (saveResult) !== 'undefined')
{
lastSavedTag = saveResult.entities[0];
}
});
});
}

Controller 调用服务方法:

function onTagAdding(tag)
{
dataServiceTagHelper.onTagAdding(tag);
}

请求负载:

"entities": [{
"Id": -1,
"Name": "sdfsdfsdf",
"Desc": null,
"entityAspect": {
"entityTypeName": "Tag:#SayusiAndo.DiLib.Model.Model.Db.Model.Blog",
"defaultResourceName": "Tags",
"entityState": "Added",
"originalValuesMap": {

},
"autoGeneratedKey": {
"propertyName": "Id",
"autoGeneratedKeyType": "Identity"
}
}
}],
"saveOptions": {

}

以下是完整的错误消息:

Error: [DiLib Error] save failed!The underlying array is null.
at createError (http://dev.dilib.local/ui/scripts/breeze.debug.js:15821:15)
at handleHttpError (http://dev.dilib.local/ui/scripts/breeze.debug.js:15811:15)
at Object.breeze.AbstractDataServiceAdapter.proto.saveChanges.ajaxImpl.ajax.error (http://dev.dilib.local/ui/scripts/breeze.debug.js:15687:9)
at errorFn (http://dev.dilib.local/ui/scripts/breeze.debug.js:16026:14)
at http://dev.dilib.local/ui/scripts/angular.js:9415:11
at processQueue (http://dev.dilib.local/ui/scripts/angular.js:13248:27)
at http://dev.dilib.local/ui/scripts/angular.js:13264:27
at Scope.$get.Scope.$eval (http://dev.dilib.local/ui/scripts/angular.js:14466:28)
at Scope.$get.Scope.$digest (http://dev.dilib.local/ui/scripts/angular.js:14282:31)
at Scope.$get.Scope.$apply (http://dev.dilib.local/ui/scripts/angular.js:14571:24)

服务器端:

StackTrace: " at System.ArraySegment`1.System.Collections.IEnumerable.GetEnumerator()
↵ at System.Data.Entity.Core.Objects.EntityEntry.TakeSnapshotOfRelationships()
↵ at System.Data.Entity.Core.Objects.ObjectContext.AddObject(String entitySetName, Object entity)
↵ at Breeze.ContextProvider.EF6.EFContextProvider`1.AddObjectStateEntry(EFEntityInfo entityInfo)
↵ at Breeze.ContextProvider.EF6.EFContextProvider`1.ProcessEntity(EFEntityInfo entityInfo)
↵ at Breeze.ContextProvider.EF6.EFContextProvider`1.ProcessSaves(Dictionary`2 saveMap)
↵ at Breeze.ContextProvider.EF6.EFContextProvider`1.SaveChangesCore(SaveWorkState saveWorkState)
↵ at Breeze.ContextProvider.ContextProvider.OpenAndSave(SaveWorkState saveWorkState)
↵ at Breeze.ContextProvider.ContextProvider.SaveChanges(JObject saveBundle, TransactionSettings transactionSettings)
↵ at SayusiAndo.DiLib.Service.WebApi.Controllers.Breeze.DiLibController.SaveChanges(JObject saveBundle) in c:\PROJECTS\sayusiando.visualstudio.com\DiLib\Dev\branches\DiLib-Dev\src\DigitalLibrary\App\DiLib\Service\DiLib.Service.WebApi\Controllers\Breeze\DiLibController.cs:line 29
↵ at lambda_method(Closure , Object , Object[] )
↵ at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.b__9(Object instance, Object[] methodParameters)
↵ at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
↵--- End of stack trace from previous location where exception was thrown ---
↵ at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
↵ at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndwindowNotification(Task task)
↵ at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
↵ at System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext()
↵--- End of stack trace from previous location where exception was thrown ---
↵ at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
↵ at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndwindowNotification(Task task)
↵ at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
↵ at System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext()
↵--- End of stack trace from previous location where exception was thrown ---
↵ at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
↵ at System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext()
↵--- End of stack trace from previous location where exception was thrown ---
↵ at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
↵ at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndwindowNotification(Task task)
↵ at System.Web.Http.Filters.ActionFilterAttribute.d__0.MoveNext()
↵--- End of stack trace from previous location where exception was thrown ---
↵ at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
↵ at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndwindowNotification(Task task)
↵ at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
↵ at System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext()
↵--- End of stack trace from previous location where exception was thrown ---
↵ at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
↵ at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndwindowNotification(Task task)
↵ at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
↵ at System.Web.Http.Controllers.ExceptionFilterResult.d__0.MoveNext()
↵--- End of stack trace from previous location where exception was thrown ---
↵ at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
↵ at System.Web.Http.Controllers.ExceptionFilterResult.d__0.MoveNext()
↵--- End of stack trace from previous location where exception was thrown ---
↵ at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
↵ at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndwindowNotification(Task task)
↵ at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
↵ at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()"

感谢您提前提供的任何帮助!

1 Câu trả lời

我找到了。我犯了两个错误。

  • 当我为对象模型创建 C# 类时,我认为需要一个数组来存储 BlogEntryTags,因此我输入“array”并按 Enter 键。 Resharper 试图提供帮助,因此它放置了 ArraySegment 而不是 List。到目前为止,它没有出现任何缺陷,因为我还没有使用过应用程序的这一部分。
  • 当我检查可能的问题时,我并没有检查breeze和db之间所有可能的问题。

现在,一切正常。

这是变化:

nhập mô tả hình ảnh ở đây

关于javascript - Breeze 底层数组在保存时出现 null 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29855182/

31 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com