资源未找到段“财产” [英] Resource not found for segment 'Property'

查看:171
本文介绍了资源未找到段“财产”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

When using ADO.Net Data Services client to refresh an entity by calling the LoadProperty:

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

它抛出一个错误的服务器上如果属性为null。

It throws an error on the server if the property is 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.DataService`1.CompareETagAndWriteResponse(RequestDescription description, ContentFormat responseFormat, IDataService dataService)
   at System.Data.Services.DataService`1.SerializeResponseBody(RequestDescription description, IDataService dataService)
   at System.Data.Services.DataService`1.HandleNonBatchRequest(RequestDescription description)
   at System.Data.Services.DataService`1.HandleRequest()

问题是,客户端不知道该属性是否为空或只是尚未填充。业主是从车辆到客户的链接。

Problem is that the client does not know whether the property is null or just hasn't been populated yet. The property Owner is a link from a Vehicle to a Customer.

任何想法有什么不对?

感谢

推荐答案

查询主键生成当键不存在异常。解决方法是在条件中添加一个虚拟的真实表达。(如:1 == 1安培;&安培; item.Id == XXX)

Querying on primary keys generate an exception when the key does not exist. The workaround is to add a dummy true expression in the condition (eg : 1==1 && item.Id == XXX).

如果没有虚拟表达ADO.NET的要求是:

Without the dummy expression the ADO.NET request is:

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

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

通过虚拟条件下,要求是:

With the dummy condition, the request is:

HTTP: //localhost//test.svc/Role()?$filter=true和(同上EQ 1)

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

预期的行为(空返回)是在第二种情况下是正确的。

The expected behaviour (null returned) is correct in the second case.

这篇关于资源未找到段“财产”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆