When I get the data using the URL in browser, I'm able to see the related data, for example:
http://localhost/services.svc/Dinners(1)/RSVPs
That lists 5 RSVPs for DinnerId = 1 in my case, but when I'm consuming the OData from a different project, I can only retrieve Dinners, debugging the app shows that RSVPs = 0, while it should be 5.
I'm consuming the service by adding a Service Reference to my project, and returning the data via 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 populated? I'm using EF (Code first - followed a post by ScottGu, with 2 very simple POCO classes for Dinner and RSVP. Dinner class have the collection of RSVPs: public ICollection<RSVP> RSVPs { get; set; }
, and the RSVP class points to the Dinner with a foreign key public int DinnerId { get; set; }
as well as the Dinner class: public Dinner Dinner { get; set; }
.
Thanks.