WCF Data Services, Expand Problem
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:SalesOrd开发者_Go百科erStageId>
<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);
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.
精彩评论