使用实体框架选择范围 [英] Select a range with Entity Framework

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

问题描述

我在尝试最大化具有页面的列表视图的性能时遇到问题.

I have an issue trying to maximize the performance of our listview that has pages.

我希望实体框架执行select语句,但只返回结果的范围(范围=列表视图一页的项目).

I want the entity framework to do a select statement, but only return a range of the result (range = the items of one page of the listview).

我已经搜索过google,但是没有找到任何结果.我只发现可以执行.ToList().GetRange(开始索引,结束索引),但是随后所有项目都将加载到内存中,这就是我要避免的事情...

I have searched google but didn't find any results on this. I only found that I can do a .ToList().GetRange(start index, end index), but then all items would be loaded in memory, and that is what I would like to avoid...

有人可以告诉我是否可以这样做? (我不想使用存储过程或视图之类的东西,因为我们的listview必须是可重用的...)

Can someone tell me if this can be done? (I don't want to use a stored procedure or view or something like that because our listview has to be reusable...)

谢谢!

推荐答案

您应该可以使用.Take(x).ToList()

对不起,请尝试.Skip(startPosition).Take(numberOfItems).ToList()

这篇关于使用实体框架选择范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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