When I get data using the URL in the browser, I can see the related data, for example:
http: //localhost/services.svc/Dinners (1) / RSVPs
This lists 5 RSVPs for DinnerId = 1 in my case, but when I consume OData from another project, I can only get lunches, debugging the application shows that RSVPs = 0, while it should be 5.
I use the service by adding a service link to my project and returning the data through a very simple LINQ query:
public ActionResult Index()
{
var result = (from d in db.Dinners
select d);
return View(result);
}
Any idea why d.RSVPs = 0 when it should be filled? I use EF (code first), after which ScottGu ships with two very simple POCO classes for Dinner and RSVP. The Dinner class has a RSVP: collection public ICollection<RSVP> RSVPs { get; set; }, and the RSVP class points to Dinner with a foreign key public int DinnerId { get; set; }, and also the Dinner: class public Dinner Dinner { get; set; }.
Thank.
source
share