DateTime start = Convert.ToDateTime(startDate);
DateTime end = Convert.ToDateTime(EndDate);
TimeSpan ts = end.Subtract(start);
int num = ts.Days;
var query = from fl in db.text.where (fl.AddTime >= start && fl.AddTime <= end)
select new
{
fl.CreateDate
};
var lmcn=query.Distinct().ToList();
List < Entity.MP.MicroChannelNum > List = new List<Entity.MP.MicroChannelNum>();
if (num <= 20)
{
for (int i = 0; i <= num; i++)
{
string da = start.AddDays(i).Date.ToString("yyyy-MM-dd");
Entity.MP.MicroChannelNum MCN = new Entity.MP.MicroChannelNum();
MCN.Date = da;
MCN.Scan = db.text.Where(f => f.MemId == MemId && f.Type == 1 && f.CreateDate == da).ToList().Count;
MCN.Follow = db.text.Where(f => f.MemId == MemId && f.Type == 2 && f.CreateDate == da).ToList().Count;
MCN.Loss = db.text.Where(f => f.MemId == MemId && f.Type == 3 && f.CreateDate == da).ToList().Count;
MCN.Growth = MCN.Follow - MCN.Loss;
List.Add(MCN);
}
}
return List;
结果