当前位置: 首页>>代码示例>>C#>>正文


C# List.GroupBy方法代码示例

本文整理汇总了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;
        }
开发者ID:noudelenferink,项目名称:TagGardening2014,代码行数:11,代码来源:TagProcessor.cs

示例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;
        }
开发者ID:caocf,项目名称:workspace-kepler,代码行数:54,代码来源:UCWareHouseAddOrEdit.cs

示例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;
 }
开发者ID:phiree,项目名称:testttt,代码行数:26,代码来源:BLLDJConsumRecord.cs

示例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;
     }
 }
开发者ID:phiree,项目名称:testttt,代码行数:11,代码来源:BLLDJConsumRecord.cs

示例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;
            }
        }
开发者ID:caocf,项目名称:workspace-kepler,代码行数:25,代码来源:UCWareHouseAddOrEdit.cs


注:本文中的Model.List.GroupBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。