I am testing OData .Net Client as following:
static void Main(string[] args)
{
var dataServiceContext = new Container(new Uri("http://localhost.fiddler:6851/"));
var selectedOrders = from order in dataServiceContext.Orders.Expand("OrderDetails")
where order.OrderId==1
select order;
DataServiceCollection<Order> orders = new DataServiceCollection<Order>(selectedOrders);
// Update Navigation
orders[0].OrderDetails[0].Quantity=9999;
dataServiceContext.SaveChanges();
}
And, I am getting an exception of
"When writing a JSON response, a user model must be specified and the entity set and entity type must be passed to the ODataMessageWriter.CreateODataEntryWriter method or the ODataFeedAndEntrySerializationInfo must be set on the ODataEntry or ODataFeed that is being written."
I also tested the same service from a browser with
http://localhost:6851/Orders(1)?$expand=OrderDetails
Then, the service returns
{ "@odata.context":"http://localhost:6851/$metadata#Orders/$entity","OrderId":1,"CustomerId":"KKKK9","OrderDetails":[
{
"OrderDetailId":1,"OrderId":1,"ProductId":1,"UnitPrice":10.00,"Quantity":1
},
{
"OrderDetailId":2,"OrderId":1,"ProductId":2,"UnitPrice":20.00,"Quantity":2
},
{
"OrderDetailId":6,"OrderId":1,"ProductId":3,"UnitPrice":30.00,"Quantity":33
}
]}
Fiddler also captures same json data to the client program, but the client modules doesn't read it and raises the exception.
If I remove the "expand", it works fine.
What am I doing wrong ?