我正在使用DbContext和POCO实体实现WCF数据服务。
我目前正在公开SalesOrder和Customer两个实体。
SalesOrder有一个名为Customer的属性,我应该能够使用此查询进行检索: http://localhost:902/ShopDataService.svc/SalesOrders()?$扩大=顾客
但是,不返回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);
答案 0 :(得分:1)
Data Services中不支持此功能。像往常一样 - 当您需要除Hello-World之外的其他东西时,您必须编写适当的应用程序,而不是尝试使用“魔术”解决方案,例如数据服务。