未找到"属性"细分的资源

gim*_*mpy 15 c# wcf-data-services

使用ADO.Net Data Services客户端通过调用以下内容刷新实体时LoadProperty:

ctx.BeginLoadProperty(this, "Owner", (IAsyncResult ar) => ...
Run Code Online (Sandbox Code Playgroud)

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

错误:异常抛出:System.Data.Services.DataServiceException:找不到段'Owner'的资源.在System.Data.Services.RequestDescription.GetSingleResultFromEnumerable(段信息段信息)在System.Data.Services.DataService1.CompareETagAndWriteResponse(RequestDescription描述,ContentFormat responseFormat,IDataService的DataService)
在System.Data.Services.DataService1.SerializeResponseBody(RequestDescription描述,IDataService的DataService )在System.Data.Services.DataService1.HandleNonBatchRequest(RequestDescription描述)在System.Data.Services.DataService`1.HandleRequest()

问题是客户端不知道该属性是否null尚未填充.财产所有者是从a Vehicle到a 的链接Customer.

有什么想法有什么不对吗?

谢谢

Pav*_*uva 33

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

svc.IgnoreResourceNotFoundException = true;
Run Code Online (Sandbox Code Playgroud)


小智 18

当密钥不存在时,查询主键会生成异常.解决方法是在条件中添加一个虚拟真实表达式(例如:1 == 1 && item.Id == XXX).

没有虚拟表达式,ADO.NET请求是:

http://localhost//test.svc/Role(XXX)

对于虚拟条件,请求是:

http://localhost//test.svc/Role()?$filter=true和(Id eq 1)

在第二种情况下,预期的行为(返回null)是正确的.