LINQ To Entities + Include + Anonymous type issue

前端 未结 3 2137
鱼传尺愫
鱼传尺愫 2020-12-03 17:54

Consider:

Class Client

Class Project

Class Ticket

Class Reply

Clients have a sub collection of projects, projects have a sub collecti

3条回答
  •  难免孤独
    2020-12-03 18:08

    Another possibility is to use StriplingWarrior's solution but then cleanse the intermediate data from the final result:

    var data = ctx.Set()
        .Select(p => new 
            { 
                Ticket = p, 
                Clients = p.Client,
                LastReplyDate = p.Replies.Max(q => q.DateCreated)
            })
        .AsEnumerable()
        .Select(p => new
            {
                Ticket = p.Ticket, 
                LastReplyDate = p.LastReplyDate
            });
    

提交回复
热议问题