本文整理汇总了C#中Model.List.GroupBy方法的典型用法代码示例。如果您正苦于以下问题:C# List.GroupBy方法的具体用法?C# List.GroupBy怎么用?C# List.GroupBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.List
的用法示例。
在下文中一共展示了List.GroupBy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSpellCheckForTags
public static List<TagProcessResult> GetSpellCheckForTags(List<TagSimple> tagSet)
{
var resultSet = new List<WordProcessResult>();
foreach (var tag in tagSet)
{
tag.TagValue.Split(' ').ToList().ForEach(w => resultSet.Add(ProcessWord(w, tag.TagId)));
}
var groupedResultSet = resultSet.GroupBy(r => r.TagId).Select(i => new TagProcessResult{ TagId = i.Key, WordProcessResultList = i.ToList()}).ToList();
return groupedResultSet;
}
示例2: ValidateJudge
/// <summary>
/// 验证是否有重复项
/// </summary>
protected bool ValidateJudge()
{
DataGridViewRowCollection ds = dgvWareHouseList.Rows;
List<DataGridViewRow> list = new List<DataGridViewRow>();
foreach (DataGridViewRow item in ds)
{
list.Add(item);
}
var ak47 = list.GroupBy(q => q.Cells[0].Value).Where(s => s.Count() > 1).Select(v => v);
if (ak47.Count() > 0)
{
//只要有一行相等就退出
MessageBoxEx.ShowError("新增加的“货位编号”重复!");
int i = 0;
foreach (var item in ak47)
{
List<DataGridViewRow> ColorRow = list.FindAll((V) =>
{
return V.Cells[0].Value.Equals(item.Key.ToString());
});
i++;
if (i == 1)
{
ColorRow.ForEach((U) =>
{
U.DefaultCellStyle.BackColor = Color.Lime;
});
}
if (i == 2)
{
ColorRow.ForEach((U) =>
{
U.DefaultCellStyle.BackColor = Color.Orange;
});
}
if (i == 3)
{
ColorRow.ForEach((U) =>
{
U.DefaultCellStyle.BackColor = Color.BlueViolet;
});
}
}
return false;
}
return true;
}
示例3: GetDJStaticsEnt
/// <summary>
/// 地接社其他企业统计信息
/// </summary>
/// <param name="dateyear">查询年份</param>
/// <param name="EntName">查询企业名称</param>
/// <param name="EntId">所在地接社id</param>
/// <returns>查询出的企业列表</returns>
public IList<DJ_TourEnterprise> GetDJStaticsEnt(string bengintime, string endtime, string EntName, int type, int EntId, bool? IsVerified_City, bool? IsVerified_Country)
{
List<DJ_GroupConsumRecord> ListRecord = GetRecordByCondition(bengintime, endtime, EntName, type, EntId, IsVerified_City, IsVerified_Country).ToList();
//过滤掉有相同团队的记录
List<DJ_GroupConsumRecord> List = new List<DJ_GroupConsumRecord>();
foreach (DJ_GroupConsumRecord item in ListRecord)
{
if (List.Where(x => x.Route.DJ_TourGroup.Id == item.Route.DJ_TourGroup.Id).Where(x => x.ConsumeTime.ToShortDateString() == item.ConsumeTime.ToShortDateString()).Where(x=>x.Enterprise.Id==item.Enterprise.Id).Count() == 0)
{
List.Add(item);
}
}
List<DJ_TourEnterprise> ListTE = new List<DJ_TourEnterprise>();
foreach (IGrouping<DJ_TourEnterprise, DJ_GroupConsumRecord> item in List.GroupBy(x => x.Enterprise).ToList())
{
ListTE.Add(item.Key);
}
return ListTE;
}
示例4: GetCountInfoByETid
public void GetCountInfoByETid(int etid, out int groupcount, out int adultcount, out int childrencount, List<DJ_GroupConsumRecord> Listrecord)
{
adultcount = 0;
childrencount = 0;
groupcount = Listrecord.GroupBy(x => x.Route.DJ_TourGroup.Id).Count();
foreach (DJ_GroupConsumRecord record in Listrecord)
{
adultcount += record.AdultsAmount;
childrencount += record.ChildrenAmount;
}
}
示例5: ValidateJudge
/// <summary>
/// 验证是否有重复项
/// </summary>
protected void ValidateJudge()
{
if (!IsValidated)
{
MessageBoxEx.ShowWarning("在增加新数据之前,需要先将之前出现的错误操作给修订");
return;
}
DataGridViewRowCollection ds = dgvWareHouseList.Rows;
List<DataGridViewRow> list = new List<DataGridViewRow>();
foreach (DataGridViewRow item in ds)
{
list.Add(item);
}
var ak47 = list.GroupBy(q => q.Cells[0].Value).Where(s => s.Count() > 1).Select(v => v);
if (ak47.Count()>0)
{
//只要有一行相等就退出
MessageBoxEx.ShowError("新增加的“货位编号”已经和“在此之前”添加的“货物编号”重复!");
IsValidated = false;
}
}