扩展methode take()将执行EF CodeFirst [英] which side the extention methode take() will execute EF CodeFirst

查看:68
本文介绍了扩展methode take()将执行EF CodeFirst的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



初学者在linq

i希望得到这样的一系列查询



选择Top 1 id From ...



i知道我可以通过


im beginner in linq
i want to get a series of queries like this

Select Top 1 id From...

i know i can do that by

IEnumerable<T>.take(1)

但我希望它在服务器数据库中执行,不仅仅是作为在本地集合中运行的函数;

当数据库是查询,它实际上是TOP(1)for take()?或者它将完整地执行查询到枚举,然后简单地采取集合中的第一个条目?

我不知道它执行哪一方。



谢谢

but i want it to execute in server database not only as a function operating in a local Collection;
When the DB is queried, will it actually be with TOP 1 for take()? Or it will execute the query in full into the enumerable, then simply take the first entry in the collection?
i dont know which side it executes.

thanks

推荐答案

请阅读文档 [ ^ ]。



Please, read the documentation[^].

MSDN写道:

Take< tsource>枚举source和yield元素,直到count元素被生成或source不包含更多元素。



如果count小于或等于零,则不枚举source并且空的IEnumerable< t>返回。

Take<tsource> enumerates source and yields elements until count elements have been yielded or source contains no more elements.

If count is less than or equal to zero, source is not enumerated and an empty IEnumerable<t> is returned.


这篇关于扩展methode take()将执行EF CodeFirst的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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