I am developing a MVC3 application and I have a problem with data retrieval . I have a list of data and i need to populate it every time . I have managed to get data and store in list but the problem for me is the StoreProc I use to populate data is itself slow and I need to run the proc time and again . I just need to store the data of list somewhere and access it globally so that i do not need to run the same proc again and again . I have to use same proc to populate data with different views. I have tried this.
I have made a model class and populated data in LIST
public List<ScheduleVO> GetScheduling(int? EmployeeId, string day)
{
List<GetSchedulingResult> schObj = pdb.GetScheduling(EmployeeId, null, null).ToList();
List<ScheduleVO> scheduleObj = new List<ScheduleVO>();
foreach (var stTime in schObj.GroupBy(x => x.StartTime))
{
GetSchedulingResult objSchedulingResult = schObj.Where(x => x.StartTime == stTime.Key).FirstOrDefault();
DateTime dtStartTime = Convert.ToDateTime(objSchedulingResult.StartTime).Date;
if (day == "Today")
{
if (dtStartTime == DateTime.Now.Date)
{
ScheduleVO vo = new ScheduleVO();
try
{
vo.scheduled = DateTime.Parse(objSchedulingResult.StartTime.ToString());
vo.ProviderName = objSchedulingResult.ProviderName;
vo.Address = objSchedulingResult.Address;
vo.Contact = objSchedulingResult.ContactName;
vo.Phone = objSchedulingResult.ContactInfo;
vo.AssignmentID = int.Parse(objSchedulingResult.Assignments_ID.ToString());
}
catch { }
scheduleObj.Add(vo);
}
public List<AssignmentVO> GetAssignment(int? EmpId, DateTime date, string day)
{
List<AssignmentVO> AssignObj = new List<AssignmentVO>();
if (day == "Today" || day == "Tomorrow")
{
List<GetSchedulingResult> schObj = pdb.GetScheduling(EmpId, null, null).ToList();
AssignObj = schObj.Where(x => x.StartTime == date).Select(y => new AssignmentVO() { ItemId = y.WorkItem_ID, Provider = y.ProviderName, HICN = y.HICNumber, Patient = y.PatientsName, DOB = DateTime.Parse(y.DOB.ToString()), Excludes = "Charts before " + y.NoIncludeCodingYearDisplayText }).ToList();
}
else if (day == "Previous")
{
List<GetPrevSchedulingResult> schObj = pdb.GetPrevScheduling(EmpId, null, null).ToList();
AssignObj = schObj.Where(x => x.StartTime == date).Select(y => new AssignmentVO() { ItemId = y.WorkItem_ID, Provider = y.ProviderName, HICN = y.HICNumber, Patient = y.PatientsName, DOB = DateTime.Parse(y.DOB.ToString()), Excludes = "Charts before " + y.NoIncludeCodingYearDisplayText }).ToList();
}
return AssignObj;
Now I just want to group the results of list and show the result in different manner in view for instance i filtered data with date. But for this I again connected to db and made a list then accessed data. I dont want to use this method because its time consuming and not efficient. Any suggestion to use the data of list globally? lets not make list time and again .