Hello Stéphane, I had the same issue.
This is my model (taken from NorthWind)
And the DomainService looks like:
[EnableClientAccess()]
public class DomainService1 : LinqToEntitiesDomainService<AdventureWorksLT2008Entities>
{
public IQueryable<Customer> GetCustomer()
{
return this.ObjectContext.Customer.Include("CustomerAddress").Include("CustomerAddress.Address");
}
}
I've added [Include] attributes on all navigation properties:
public partial class Customer
{
internal sealed class CustomerMetadata
{
// Metadata classes are not meant to be instantiated.
private CustomerMetadata() { }
public string CompanyName { get; set; }
[Include]
public EntityCollection<CustomerAddress> CustomerAddress { get; set; }
And in the client code, I use this:
var dc = new MyDomainContext();
var query = dc.GetCustomerQuery();
var op = dc.Load(query, loadOperation =>
{
var customer = loadOperation.Entities.FirstOrDefault();
var address = customer.CustomerAddress.FirstOrDefault().Address;
}, null);
Note that this does only work when:
- ObjectContext is auto generated by EntityFramework (no custom Context or Poco entities)
- The DomainService is a 'LinqToEntitiesDomainService'
See also this link.