8,497
社区成员
发帖
与我相关
我的任务
分享
from a in datas
join b in cab on a.ServiceOrderId equals b.ServiceOrderId
join c in sod on b.idequals c.cabid
select new { a,b, c};
[/quote]
那其实比较简单,就是a,b,c三标互联,
然后获取各组中,c表typeid最大的那个。
我给你个例子,你照着改改
static void Main(string[] args)
{
var q = from a in myList //a表
join b in myList1 on a.ID equals b.ID //b表
group b by b.ID into g //根据id分组
select new //查询出需要的字段
{
Id = g.Key, //分组字段
Age = g.Max(x => x.Age) //分组中,最大的Age
};
Console.ReadLine();
}
from a in datas
join b in cab on a.ServiceOrderId equals b.ServiceOrderId
join c in sod on b.idequals c.cabid
select new { a,b, c};
from a in datas
join b in cab.GroupBy(g=>g.ServiceOrderId).Select(s=>new{ServiceOrderId=s.Key,abc = s.Max(m=>m.你需要的字段)})
on a.ServiceOrderId equals b.ServiceOrderId