givemesomedownloads
New Member
I have an MVC app that is using the repository pattern. When I load the class, I make a call in the constructor to fill my ticket repo. After page load I have some functions (ajax calls) that make calculations of the fill repo. These queries are peaking my IIS 6 machine when running and take anywhere from 2-4 seconds to complete (each). My local machine processes these quickly... any tips?Here is a piece of my controller:\[code\]Public Class DashboardController Inherits BaseController Private db As TicketContext = New TicketContext Private ticketRepo As MaintenanceTicketsRepository Private tickets = Nothing Public Sub New() Me.ticketRepo = New MaintenanceTicketsRepository(New TicketContext) tickets = ticketRepo.GetAll().Include(Function(p) p.Priority).Include(Function(s) s.Status).OrderBy(Function(o) o.PriorityId).ToArray() End Sub Function Chart_OpenItemsByPM() As ActionResult 'Dim tickets = ticketRepo.GetAll().Include(Function(p) p.Priority).Include(Function(s) s.Status).OrderBy(Function(o) o.PriorityId).ToArray() Mapper.CreateMap(Of MaintenanceTicket, PieChartViewModel)() Dim queue As PieChartViewModel() = Mapper.Map(Of MaintenanceTicket(), PieChartViewModel())(tickets) Dim ticketCounts = From t In queue _ Where t.StatusName = "Open" And _ t.PriorityName <> "Not Ready" _ Group t By t.PriorityName Into Count() _ Select PriorityName, Id = Count Return Json(ticketCounts) End Function Function Grid_OpenItemsByPriority(<DataSourceRequest()> request As DataSourceRequest) As ActionResult 'Dim tickets = ticketRepo.GetAll().Include(Function(p) p.Priority).Include(Function(s) s.Status).ToArray() Mapper.CreateMap(Of MaintenanceTicket, GridViewModel)() Dim queue As GridViewModel() = Mapper.Map(Of MaintenanceTicket(), GridViewModel())(tickets) Dim ticketCounts = From t In queue _ Where _ t.StatusId = 1 And _ t.CreateDate.Year = Convert.ToDateTime(DateTime.Now).Year _ Group t By _ Column1 = CType(t.CreateDate.Month, Integer), _ Column2 = CType(t.CreateDate.ToString("MMMM"), String) _ Into g = Group _ Order By Column1 _ Select _ Id = Column1, _ Month = Column2, _ Critical = g.Count(Function(t) t.PriorityId = 1), _ High = g.Count(Function(t) t.PriorityId = 2), _ Normal = g.Count(Function(t) t.PriorityId = 3), _ Low = g.Count(Function(t) t.PriorityId = 4), _ NotReady = g.Count(Function(t) t.PriorityId = 5), _ Total = g.Count(Function(t) t.Id <> Nothing) Return Json(ticketCounts.ToDataSourceResult(request)) End Function\[/code\]