• 一个Linq


    public class CalendaerCollectItem
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public int Finished { get; set; }
        public int NotFinished { get; set; }
    }
    ////按照员工ManagerUserID筛选出最终要显示的结果
                var query = from t in dtSource.AsEnumerable()
                            group t by new { t1 = t.Field<Int16>("ManagerUserId"), t2 = t.Field<string>("Name") }
                                into m
                                select new
                                {
                                    ID = m.Key.t1,//ManagerUserID
                                    Name = m.Key.t2,//客服的名字
                                    Finished = m.Count(n => n.Field<Int16>("status").Equals(2)), //统计完成的
                                    NotFinished = m.Count(n => n.Field<Int16>("status").Equals(1)) //统计未完成的
                                };
                //存到List中提交到前台
                List<CalendaerCollectItem> list = new List<CalendaerCollectItem>();
                query.ToList().ForEach(a =>
                {
                    CalendaerCollectItem item = new CalendaerCollectItem();
                    item.ID = a.ID;
                    item.Name = a.Name;
                    item.Finished = a.Finished;
                    item.NotFinished = a.NotFinished;
                    list.Add(item);
                });
  • 相关阅读:
    python函数嵌套的实用技术
    windows10 装linux子系统
    彻底测试全部拷贝list相关操作的区别python
    c语言学习
    Pickling
    Filenames and paths
    Format operator
    Reading and writing
    Persistence
    Automation testing tool comparison
  • 原文地址:https://www.cnblogs.com/ustcyc/p/4211275.html
Copyright © 2020-2023  润新知