开发者

HOw to Include many level objects in LINQ Queries

im using Silverlight and Ria services i have the following linq function in ria that returns an object called DependantPerson:

    public IQueryable<DependantPerson> GetDependantPersons(int PerID)
    {
        return this.ObjectContext.DependantPerson
            .Include("Person1")
            .Where(dp => dp.Person_FK == PerID)
            .OrderBy(dp => dp.ID);
    }

now DependantPerson is related 开发者_开发百科to another Object called Person1 wich i included in this query, and Person1 is in turn related to a third Object called SimpleListValue, How can i tell LINQ that i also what to inclue SimpleListValue in Person1 so i can later use it in binding at XAML side as following:

...sdk:Label Content="{Binding Person1.MotherName}"

...sdk:Label Content="{Binding Person1.SimpleListValue.Label}"

the first example Person1.MotherName works just fine but the second Person1.SimpleListValue.Label is not working and i think the problem is my LINQ query

any help is appreciated thank you for your time and bear with me


Use DataLoadOptions.LoadWith()

See examples here: http://msdn.microsoft.com/en-us/library/Bb386917(v=VS.90).aspx

You must specify DataLoadOptions and assign in to the DataContext instance before executing any queries.

this is an answer jay gave me on my post. I hope this helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜