Search code examples
c#silverlightwcf-ria-services

debugging loadwith has subnodes in domainservice, but not when called in viewmodel


I'm trying to use the .LoadWith method

I have these lines of code in my domainservice:

public IEnumerable<Subject> GetSubjectList(Guid userid)
        {
            DataLoadOptions loadopts = new DataLoadOptions();
            loadopts.LoadWith<Subject>(s => s.Notes);
            this.DataContext.LoadOptions = loadopts;
            return this.DataContext.Subjects;
        }

I can see debugging that a list of subjects get loaded, and that the Subjects.Notes property which is a List is also populated with subitems, but when I do

ctx.Load(ctx.GetSubjectListQuery(WebContext.Current.User.UserId), lo => 
                {
                    serverdata = ctx.Subjects; 
                }, null);

I only get a flat list of subjects loaded into serverdata, and no note subitems are loaded to subject.notes


Solution

  • I had not added [Include] to my metadata properties of my domainservice.