gpt4 book ai didi

c# - 找不到段 'Property' 的资源

转载 作者:可可西里 更新时间:2023-11-01 03:12:06 25 4
gpt4 key购买 nike

当使用 ADO.Net 数据服务客户端通过调用 LoadProperty 刷新实体时:

ctx.BeginLoadProperty(this, "Owner", (IAsyncResult ar) => ...

如果属性为null,它会在服务器上抛出一个错误

Error: Exception Thrown: System.Data.Services.DataServiceException: Resource not found for the segment 'Owner'. at System.Data.Services.RequestDescription.GetSingleResultFromEnumerable(SegmentInfo segmentInfo) at System.Data.Services.DataService1.CompareETagAndWriteResponse(RequestDescription description, ContentFormat responseFormat, IDataService dataService)
at System.Data.Services.DataService1.SerializeResponseBody(RequestDescription description, IDataService dataService) at System.Data.Services.DataService1.HandleNonBatchRequest(RequestDescription description) at System.Data.Services.DataService`1.HandleRequest()

问题是客户端不知道该属性是 null 还是尚未填充。属性 Owner 是从 VehicleCustomer 的链接。

有什么问题吗?

谢谢

最佳答案

设置IgnoreResourceNotFoundException服务上下文的属性为真:

svc.IgnoreResourceNotFoundException = true;

关于c# - 找不到段 'Property' 的资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/505761/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com