I had to create a small chart about Asp.Net Membership users. The easy way how to do this is to use the Method GetAllUsers(). Once we loaded all Membership data we ready to run over our data with 2 simple LINQ statements:
DateTime now = DateTime.UtcNow;
Dictionary<datetime,> day = new Dictionary<datetime,>();
for (int i = 0; i < 7; ++i)
{
DateTime compareDate = new DateTime(now.Year, now.Month, now.Day);
compareDate = compareDate.AddDays(-i);
var d = from a in data
where a.CreationDate.Year == compareDate.Year &&
a.CreationDate.Month == compareDate.Month &&
a.CreationDate.Day == compareDate.Day
orderby a.CreationDate descending
select a;
day.Add(compareDate, d.Count());
}
Dictionary<datetime,> month = new Dictionary<datetime,>();
for (int i = 0; i < 12; ++i)
{
DateTime compareDate = new DateTime(now.Year, now.Month, now.Day);
compareDate = compareDate.AddMonths(-i);
var d = from a in data
where a.CreationDate.Year == compareDate.Year &&
a.CreationDate.Month == compareDate.Month
orderby a.CreationDate descending
select a;
month.Add(compareDate, d.Count());
}
No comments:
Post a Comment