public static List <Office> GetOffices(bool activeOnly) { List <Office> offices; using (CustomClearviewEntities ctx = new CustomClearviewEntities()) { OfficeRepository repo = new OfficeRepository(ctx); offices = activeOnly ? repo.Filter(v => v.IsActive, sort => sort.OfficeName, SortOrder.Ascending, type => type.Vendor, type => type.Users) : repo.All(t => t.Users, type => type.Vendor, type => type.Users); } return(offices); }