开发者

how to create a linq query using join and max

I have 2 tables in my linq dbml. One is people with a uniqueid called peopleid and the other is a vertical with a foreign key for peopleid and a uniqueid called id. I need to create a type of linq query that does 开发者_运维问答a left outer join on people and gets the latest record in the vertical table based off the max(id) column. Can anyone suggest what this should look like? Thanks.


It should look like this (just a suggestion):

from p in con.Peoples
orderby p.LastName , p.FirstName
let maxPrint = p.FingerPrints
   .OrderByDescending(fp => fp.Id)
   .FirstOrDefault()
where maxPrint != null
select new {
  p.PeopleID,
  Name = p.FirstName + " " + p.LastName,
  FingerPrint = maxPrint
};
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜