Показаны сообщения с ярлыком DateTime. Показать все сообщения
Показаны сообщения с ярлыком DateTime. Показать все сообщения

понедельник, 2 февраля 2015 г.

EntityFrameWork group by some ?

context.Users
    .Where((x.LastLogIn  >= lastWeek) && (x.LastLogIn <= DateTime.Now))
    .GroupBy(x => EntityFunctions.TruncateTime(x.LastLogIn))
    .Select(x => new
    {
        Value = x.Count(),
        // Replace the commented line
        //Day = (DateTime)EntityFunctions.TruncateTime(x.Key)
        // ...with this line
        Day = (DateTime)x.Key
    }).ToList();

  .GroupBy(x => new {Year = x.LastLogIn.Year, Month = x.LastLogIn.Month, Day = x.LastLogIn.Day)
            .Select(x => new
                {
                    Value = x.Count(),
                    Year = x.Key.Year,
                    Month = x.Key.Month,
                    Day = x.Key.Day
                })

пятница, 3 октября 2014 г.

GetWeekOfYear()

DateTimeFormatInfo.Calendar

 private int GetWeekOfYear(DateTime DT)
        {
            return
DateTimeFormatInfo.Calendar.GetWeekOfYear(DT, dfi.CalendarWeekRule, dfi.FirstDayOfWeek);
        }