1
Grid in MVC - I have a lot of data to return and I didn’t want to bring all of a single see even why there is paging. How do I get 10 records? Which grid to use together with MVC and Entity Framework. In the example below I bring it all.
Itens itensmedicos = itensmedicos.where(x => x.ativos = true).ToList();
I put it on a grid and it shows right the only problem is it takes too long.
I don’t know what that’s like
itensmedicos
but the problem isToList()
. Use whatever you want to paginate, if you don’t change this you will still have a performance problem because you are bringing all the data. You probably need to adapt to something like thisSkip(page*pagesize).Take(pagesize)
. Two tips: http://answall.com/questions/31646/padr%C3%A3o-de-nomenclature-no-c%C3%B3digo-para-o-c/32665#32665 try to give variable names easier to read. Do not compare againsttrue
when the expected result is a boolean. Simplify:where(x => x.ativos)
– Maniero
There are some answers to very similar questions: - http://answall.com/questions/23694/pagina%C3%A7%C3%A3o-mvc-Asp-net/23697#23697 - http://answall.com/questions/29722/como-uso-skip-e-take-com-o-helper-pagedlist/29821#29821 - http://answall.com/questions/23398/utilizar-ipagedlist-com-v%C3%A1rios-resultados/23399#23399
– Leonel Sanches da Silva