本文整理汇总了C#中System.Collections.Generic.List.GroupBy方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.List.GroupBy方法的具体用法?C# System.Collections.Generic.List.GroupBy怎么用?C# System.Collections.Generic.List.GroupBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic.List
的用法示例。
在下文中一共展示了System.Collections.Generic.List.GroupBy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ContrastProductionPlan
private void ContrastProductionPlan(int version1, int version2, string item)
{
var mstrs1 = TheGenericMgr.FindAllWithCustomQuery<ProductionPlanMstr>("select m from ProductionPlanMstr as m where m.ReleaseNo=?", version1);
var mstrs2 = TheGenericMgr.FindAllWithCustomQuery<ProductionPlanMstr>("select m from ProductionPlanMstr as m where m.ReleaseNo=?", version2);
if (mstrs1 == null || mstrs1.Count == 0)
{
this.Resultlist.InnerHtml = "";
ShowErrorMessage(string.Format("版本号{0}不存在,请确认。", version1));
return;
}
if (mstrs2 == null || mstrs2.Count == 0)
{
this.Resultlist.InnerHtml = "";
ShowErrorMessage(string.Format("版本号{0}不存在,请确认。", version2));
return;
}
string searchHql = " select d from ProductionPlanDet as d where Type='Daily' ";
if (!string.IsNullOrEmpty(item))
{
searchHql += string.Format(" and d.Item='{0}' ", item);
}
var dets1 = TheGenericMgr.FindAllWithCustomQuery<ProductionPlanDet>(searchHql + " and d.ProductionPlanId= " + mstrs1.First().Id);
var dets2 = TheGenericMgr.FindAllWithCustomQuery<ProductionPlanDet>(searchHql + " and d.ProductionPlanId= " + mstrs2.First().Id);
var minStartTime1 = dets1.Min(s => s.StartTime);
dets1 = (from d in dets1
where d.StartTime < minStartTime1.AddDays(14)
select d).ToList();
var minStartTime2 = dets2.Min(s => s.StartTime);
dets2 = (from d in dets2
where d.StartTime < minStartTime2.AddDays(14)
select d).ToList();
var allResult1 = new System.Collections.Generic.List<ProductionPlanDet>();
allResult1.AddRange(dets1);
allResult1.AddRange(dets2);
var planByFlowItems = allResult1.GroupBy(p => new { p.Item });
var sTime = minStartTime1 < minStartTime2 ? minStartTime1 : minStartTime2;
var eTime = minStartTime1 < minStartTime2 ? minStartTime2 : minStartTime1;
StringBuilder str = new StringBuilder();
str.Append("<table id='tt' runat='server' border='1' class='GV' style='width:150%;border-collapse:collapse;'>");
str.Append("<thead><tr class='GVHeader'><th rowspan='2'>序号</th><th rowspan='2'>物料号</th><th rowspan='2'>物料描述</th><th rowspan='2'>客户零件号</th>");
if (sTime.AddDays(14) <= eTime)
{
for (int i = 0; i < 28; i++)
{
if (i <= 14)
{
str.Append("<th colspan='2'>");
str.Append(sTime.ToString("yyyy-MM-dd"));
str.Append("</th>");
sTime = sTime.AddDays(1);
}
else
{
str.Append("<th colspan='2'>");
str.Append(eTime.ToString("yyyy-MM-dd"));
str.Append("</th>");
eTime = eTime.AddDays(1);
}
}
str.Append("</tr><tr class='GVHeader'>");
for (int i = 0; i < 28; i++)
{
str.Append(string.Format("<th >{0}</th><th >{1}</th>", version1, version2));
}
}
else
{
while (sTime <= eTime.AddDays(14))
{
str.Append("<th colspan='2'>");
str.Append(sTime.ToString("yyyy-MM-dd"));
str.Append("</th>");
sTime = sTime.AddDays(1);
}
str.Append("</tr><tr class='GVHeader'>");
sTime = minStartTime1 < minStartTime2 ? minStartTime1 : minStartTime2;
while (sTime <= eTime.AddDays(14))
{
str.Append(string.Format("<th >{0}</th><th >{1}</th>", version1, version2));
sTime = sTime.AddDays(1);
}
}
str.Append("</tr></thead>");
str.Append("<tbody>");
int l = 0;
foreach (var planByFlowItem in planByFlowItems)
{
var firstPlan = planByFlowItem.First();
//.........这里部分代码省略.........