且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Linq查询根据孙子的属性返回祖父母,父母和孙子

更新时间:2022-05-30 23:05:20

您应该能够执行以下操作,以获取符合任何条件的计划以及其父对象和祖父母对象:

You should be able to do something like this to get the plans which meet whatever criteria, along with their parent and grandparent objects:

// results is an anonymous type with properties Quote, Rate, Plan
var results = from q in quotes
    from r in q.Rates
    from p in r.Plans
    where p.Id < 500 /* whatever criteria */
    select new 
    {
        Quote = q,
        Rate = r,
        Plan = p
    };