#region
        string Condition(DateTime date, string type)
        {
            if (date == null)
            {
                date = DateTime.MinValue;
            }

            if (type == "day")
            {
                return date.ToString("yyyy-M-d");
            }
            else if (type == "month")
            {
                return date.ToString("yyyy-M");
            }
            return date.Year.ToString();
        }
        public void xx()
        {
            List<DateTime> datelist = new List<DateTime>();
            var today = DateTime.Now.Date;
            for (var i = 0; i < 7;i++ )
            {
                datelist.Add(today.AddDays(-i));
            }

            var oderlist = this.Find().AsEnumerable();
            var result = from m in datelist
                         join n in oderlist on Condition(m, "day") equals Condition(n.create_time, "day") into c
                         from cc in c.DefaultIfEmpty()
                         group cc by Condition(m, "day") into g
                         select new { g.Key, Total = (g.FirstOrDefault()==null?0:g.Count())};

            var ccc = result.ToList();

        }
        #endregion

相关文章:

  • 2021-10-06
  • 2022-12-23
  • 2022-12-23
  • 2021-12-16
  • 2021-11-12
  • 2021-07-15
猜你喜欢
  • 2021-05-27
  • 2022-02-01
  • 2021-08-27
  • 2019-05-22
  • 2022-01-07
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案