实体框架要列出的超大表 [英] Entity Framework Very Large Table to List

查看:32
本文介绍了实体框架要列出的超大表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的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.

查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆