List 与 table 分组(group by )
1.list 分组
List<ADSPkgMasterInfo> packageList= BizUIRequestAssetTag.GetUIRequestAsset_Rel_PackageNameInfo(_UIRequestID, _isDraft);
var aa = from item in packageList
group item by new { item.PkgName, item.PkgMasterID } into g
select new
{
PkgName = g.Key.PkgName,
PkgMasterID = g.Key.PkgMasterID
};
2.table 分组
var Query = from t in dtACCQueryInfo.AsEnumerable()
group t by new
{
s = t.Field<string>("SenseVersion"),
d = t.Field<string>("Device"),
a = t.Field<string>("APName"),
fn = t.Field<string>("OwnerName"),
Fd = t.Field<string>("CodeFreezeDate")
}
into m
select new
{
SenseVersion = m.Key.s,
Device = m.Key.d,
APName = m.Key.a,
OwnerName = m.Key.fn,
CodeFreezeDate = m.Key.Fd,
count = m.Count()
};