當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。