CodeGo.net> Linq to SQL与分组依据
作者:互联网
我正在尝试将此T-SQL转换为Linq To SQL,但无法通过聚合函数计算出该组.任何帮助欢迎.
select c.ClientID, GivenName, Surname, max(a.Address), max(t.Value)
from Client c
left join ClientAddress a on c.ClientID = a.ClientID
left join ClientContact t on c.ClientID = t.ClientID
group by c.ClientID, GivenName, Surname
解决方法:
要按组合键分组,通常使用匿名类型:
var qry = from x in someSource
group x by new { x.ClientID, x.GivenName, x.Surname } into grp
select new { grp.Key, Address = grp.Max(x => x.Address),
Value = grp.Max(x => x.Value) };
标签:linq-to-sql,c,tsql 来源: https://codeday.me/bug/20191210/2102487.html