Aggelos Biboudis
Aggelos Biboudis

Reputation: 1195

How to eager load in WCF Ria Services/Linq2SQLDomainModel

I have a databound grid at my view (XAML) and the Itemsource points to a ReportsCollection. The Reports entity has three primitives and some complex types. These three are shown as expected at datagrid. Additionally the Reports entity has a property of type Store. When loading Reports via GetReports domain method, I quickly figure out that only primitives are returned and not the whole graph of some depth. So, as I wanted to load the Store property too, I made this alteration at my domain service:

public IQueryable<Report> GetReports()
{
    return this.ObjectContext.Reports.Include("Store");
}

From what I see at the immediate window, store is loaded as expected, but when returned to client is still pruned. How can this be fixed?

Thank you!

Upvotes: 0

Views: 1068

Answers (1)

Kevin Hodges
Kevin Hodges

Reputation: 26

Decorate the Store property in the ReportMetadata class with [Include].

[MetadataTypeAttribute(typeof(Report.ReportMetadata))]
public partial class Report
{
    internal sealed class ReportMetadata
    {
        [Include]
        public Store Store;
    }
}

Upvotes: 1

Related Questions