实体框架要列出的超大表 [英] Entity Framework Very Large Table to List
问题描述
我的Microsoft SQL服务器中有一个表,其中包含约11,450,112行,我正准备使用此命令:
I have a table in my Microsoft SQL server with about 11,450,112 rows, I'am tring to use this command:
contex.TableName.ToList();
contex.TableName.ToList();
问题在于表太大,VB2010抛出"OutOfMemory"异常.
The problem is becuase the table is so big, the VB2010 throws an "OutOfMemory" exception.
我在想,也许有一个命令可以将查询分隔到页面之类的东西中.
I was thinking maybe theres a command to seprarete the query in to pages or something like that.
任何想法或任何帮助都会对我有很大帮助.
Any ideas or any help would help me very much.
谢谢.
推荐答案
您可以使用Entity Framework轻松进行分页,
You can easily do paging with Entity Framework,
contex.TableName.Skip(pages*pageSize).Take(pageSize).ToList();
在客户端,您需要实现一些分页机制,以根据用户输入传递 page
和 pageSize
参数.
In the client side you need to implement some paging mechanism to pass the page
and pageSize
parameters according to the users input.