У меня была та же проблема.
Это моя модель (из Northwind)
alt text http://i33.tinypic.com/5k0g3n.png
И DomainService выглядит следующим образом:
[EnableClientAccess()]
public class DomainService1 : LinqToEntitiesDomainService<AdventureWorksLT2008Entities>
{
public IQueryable<Customer> GetCustomer()
{
return this.ObjectContext.Customer.Include("CustomerAddress").Include("CustomerAddress.Address");
}
}
Я добавил [Включить] атрибуты всех навигации свойства:
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; }
И в коде клиента, я использую это:
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);
Обратите внимание, что это только работает, когда:
- ObjectContext является автогенерируемая по EntityFramework (без пользовательского контекста или Poco юридические лица)
- DomainService является «LinqToEntitiesDomainService»
См. Также this link.
Желание Я мог бы найти один экземпляр этого же вопроса, на который у кого-то есть ответ. http://stackoverflow.com/questions/2624348/ria-services-not-returning-included-type-collection-property http://stackoverflow.com/questions/2603145/ria-services-entity-with-collection-is -empty-когда-не-должен-к –