public List <DNUserItem> GetAllByAgencyId(int agencyId, int month) { var monthstart = ConvertDate.TotalSecondsMonth(month); var monthend = ConvertDate.TotalSecondsMonth(month + 1); var query = from o in FDIDB.DN_Users where o.AgencyID == agencyId && (o.DN_EDIT_Schedule.Any(m => m.Datecreated >= monthstart && m.Datecreated <= monthend) || o.DN_EDIT_Schedule1.Any(m => m.Datecreated >= monthstart && m.Datecreated <= monthend)) select new DNUserItem { UserId = o.UserId, DN_EDIT_Schedule = o.DN_EDIT_Schedule.Select(m => new EditScheduleItem { ID = m.ID, }), DN_EDIT_Schedule1 = o.DN_EDIT_Schedule1.Select(m => new EditScheduleItem { ID = m.ID, }) }; return(query.ToList()); }