public IQueryable <AgencyReportingHomecareDetailsRow> GetAgencyReportingData(CC.Data.ccEntities db, CC.Data.Services.IPermissionsBase permissions) { db.CommandTimeout = 600; var source = db.spAgencyReportingHomecareDetails(this.CurId, this.StartDate, this.EndDate , !this.IncludeNotSubmittedReports , this.AgencyId , this.RegionId , this.CountryId , this.StateId , this.ServiceId , this.MasterFundId , this.FundId , this.AppId , this.ClientId , this.sSearch , this.sSortCol_0 , this.sSortDir_0 == "asc" , this.iDisplayLength == int.MaxValue ? int.MaxValue : this.iDisplayLength + 1 , this.iDisplayStart , permissions.User.Id).ToList(); DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo; Calendar cal = dfi.Calendar; var q = from item in source select new AgencyReportingHomecareDetailsRow { AgencyId = item.AgencyId, Cur = this.CurId, ClientId = item.ClientId, FundName = item.FundName, AppName = item.AppName, ServiceName = item.ServiceName, Quantity = item.Quantity, Rate = item.Rate, Amount = item.Amount, Date = item.ReportDate, IsWeekly = item.IsWeekly.Value, WeekNumber = "W" + (item.IsWeekly.Value ? (cal.GetWeekOfYear(item.ReportDate, dfi.CalendarWeekRule, item.SelectedDayOfWeek != null ? (DayOfWeek)item.SelectedDayOfWeek : item.MrStart.DayOfWeek)).ToString() : item.ReportDate.Month.ToString()) }; return(q.AsQueryable()); }