首页 > 代码库 > lambda group by 的用法
lambda group by 的用法
foreach (DynamicObject lstKSItem in lstKSItems)
{
var entity = lstKSItem["FEntity"] as DynamicObjectCollection;
if (entity.Count == 0) continue;
var groupKeys = entity.Select(p => new
{
FShirtOrdNO = Convert.ToString(p["FShirtOrdNO"]),
FKeyWorkCenterE_Id =
Convert.ToString(p["FKeyWorkCenterE_Id"])
}).GroupBy(p => new {p.FShirtOrdNO,p.FKeyWorkCenterE_Id });//根据FShirtOrdNO,FKeyWorkCenterE_Id分组
if (groupKeys.Count() > 1)
{
foreach (var groupKey in groupKeys)
{
;
var DataEntityCopy = OrmUtils.Clone(lstKSItem, lstKSItem.DynamicObjectType, true, true) as DynamicObject;
var DataEntityCopyObjs = DataEntityCopy["FEntity"] as DynamicObjectCollection;
DataEntityCopyObjs.Clear();
var groupByShirtOrdNOObjs = entity.Where(o => Convert.ToString(o["FShirtOrdNO"]) == groupKey.Key.FShirtOrdNO
&& Convert.ToString("FKeyWorkCenterE_Id")==groupKey.Key.FKeyWorkCenterE_Id).ToArray<DynamicObject>();//
int i = 0;
foreach (DynamicObject groupByShirtOrdNOObj in groupByShirtOrdNOObjs)
{
groupByShirtOrdNOObj["Seq"] = ++i;
DataEntityCopyObjs.Add(groupByShirtOrdNOObj);
}
decimal SumQty = (DataEntityCopy["FEntity"] as DynamicObjectCollection).Sum(o => Convert.ToDecimal(o["FReportQty"]));
DataEntityCopy["FSumQty"] = SumQty;
AddGroupItems.Add(DataEntityCopy);
}
}
else
{
AddGroupItems.Add(lstKSItem);
}
lambda group by 的用法
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。