WCF 数据服务,展开问题
我正在使用 DbContext 和 POCO 实体实现 WCF 数据服务。
我当前公开两个实体:SalesOrder 和 Customer。
SalesOrder 有一个名为 Customer 的属性,我应该能够使用以下查询检索该属性: http://localhost:902/ShopDataService.svc/SalesOrders()?$expand=客户
但是,不返回 Customer 对象。这是返回的每个条目(SalesOrder)的 XML 块...
<entry>
<id>http://localhost:902/ShopDataService.svc/SalesOrders(60)</id>
<title type="text"></title>
<updated>2011-03-17T14:58:11Z</updated>
<author>
<name />
</author>
<link rel="edit" title="SalesOrder" href="SalesOrders(60)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ShippingAddress" type="application/atom+xml;type=entry" title="ShippingAddress" href="SalesOrders(60)/ShippingAddress" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/InvoiceAddress" type="application/atom+xml;type=entry" title="InvoiceAddress" href="SalesOrders(60)/InvoiceAddress" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Customer" type="application/atom+xml;type=entry" title="Customer" href="SalesOrders(60)/Customer">
<m:inline />
</link>
<category term="CarterShop.Commerce.Entities.SalesOrder" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<content type="application/xml">
<m:properties>
<d:Id m:type="Edm.Int32">60</d:Id>
<d:Created m:type="Edm.DateTime">2011-03-12T15:23:47.07</d:Created>
<d:ItemCost m:type="Edm.Decimal">8.00</d:ItemCost>
<d:ShippingCost m:type="Edm.Decimal">0.00</d:ShippingCost>
<d:ShippingVat m:type="Edm.Decimal">0.00</d:ShippingVat>
<d:ItemVat m:type="Edm.Decimal">1.60</d:ItemVat>
<d:Total m:type="Edm.Decimal">9.60</d:Total>
<d:ShippingAddressId m:type="Edm.Int32" m:null="true" />
<d:InvoiceAddressId m:type="Edm.Int32" m:null="true" />
<d:Paid m:type="Edm.DateTime" m:null="true" />
<d:Shipped m:type="Edm.DateTime" m:null="true" />
<d:TransactionId m:null="true" />
<d:OrderNumber>000068</d:OrderNumber>
<d:SalesOrderStageId m:type="Edm.Int32">2</d:SalesOrderStageId>
<d:CustomerId m:type="Edm.Int32">2</d:CustomerId>
<d:CancellationReasonId m:type="Edm.Int32" m:null="true" />
<d:ShippingBracketId m:type="Edm.Int32" m:null="true" />
</m:properties>
</content>
您可以看出它正在尝试返回 Customer 对象,因为它正在发送该元素,就好像它没有属性一样,但它的配置与 SalesOrder 实体完全相同。
以前有人遇到过这个问题吗? 编辑: 我像这样公开数据(所以没有权限问题)。
config.SetEntitySetAccessRule("SalesOrders", EntitySetRights.All);
config.SetEntitySetAccessRule("Customers", EntitySetRights.All);
config.SetEntitySetAccessRule("Addresses", EntitySetRights.All);
I am implementing WCF Data Services using a DbContext and POCO entities.
I am currently exposing two entities, SalesOrder and Customer.
SalesOrder has a property called Customer, which I should be able to retrive using this query:
http://localhost:902/ShopDataService.svc/SalesOrders()?$expand=Customer
However, no Customer object is returned. This is the XML block for each entry (of SalesOrder) that is returned...
<entry>
<id>http://localhost:902/ShopDataService.svc/SalesOrders(60)</id>
<title type="text"></title>
<updated>2011-03-17T14:58:11Z</updated>
<author>
<name />
</author>
<link rel="edit" title="SalesOrder" href="SalesOrders(60)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ShippingAddress" type="application/atom+xml;type=entry" title="ShippingAddress" href="SalesOrders(60)/ShippingAddress" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/InvoiceAddress" type="application/atom+xml;type=entry" title="InvoiceAddress" href="SalesOrders(60)/InvoiceAddress" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Customer" type="application/atom+xml;type=entry" title="Customer" href="SalesOrders(60)/Customer">
<m:inline />
</link>
<category term="CarterShop.Commerce.Entities.SalesOrder" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<content type="application/xml">
<m:properties>
<d:Id m:type="Edm.Int32">60</d:Id>
<d:Created m:type="Edm.DateTime">2011-03-12T15:23:47.07</d:Created>
<d:ItemCost m:type="Edm.Decimal">8.00</d:ItemCost>
<d:ShippingCost m:type="Edm.Decimal">0.00</d:ShippingCost>
<d:ShippingVat m:type="Edm.Decimal">0.00</d:ShippingVat>
<d:ItemVat m:type="Edm.Decimal">1.60</d:ItemVat>
<d:Total m:type="Edm.Decimal">9.60</d:Total>
<d:ShippingAddressId m:type="Edm.Int32" m:null="true" />
<d:InvoiceAddressId m:type="Edm.Int32" m:null="true" />
<d:Paid m:type="Edm.DateTime" m:null="true" />
<d:Shipped m:type="Edm.DateTime" m:null="true" />
<d:TransactionId m:null="true" />
<d:OrderNumber>000068</d:OrderNumber>
<d:SalesOrderStageId m:type="Edm.Int32">2</d:SalesOrderStageId>
<d:CustomerId m:type="Edm.Int32">2</d:CustomerId>
<d:CancellationReasonId m:type="Edm.Int32" m:null="true" />
<d:ShippingBracketId m:type="Edm.Int32" m:null="true" />
</m:properties>
</content>
You can tell it is trying to return the Customer object, because it is sending that element, as if it has no properties, but it is configured exactly the same as the SalesOrder entity.
Has anyone hit this issue before?
Edit:
I am exposing the data like this (so no permissions problems).
config.SetEntitySetAccessRule("SalesOrders", EntitySetRights.All);
config.SetEntitySetAccessRule("Customers", EntitySetRights.All);
config.SetEntitySetAccessRule("Addresses", EntitySetRights.All);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
数据服务中不正确支持这一点。与往常一样,当您需要 Hello-World 之外的其他功能时,您必须编写适当的应用程序,而不是尝试使用数据服务等“神奇”解决方案。
This is not properly supported in Data Services. As usual - when you need something apart from Hello-World, you must write proper applications, rather than try to use 'magic' solutions such as Data Services.