实体框架-Where子句 [英] Entity Framework - Where Clause

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

问题描述

比方说,我有一个名为User的表. 当我使用实体框架获取记录时,我会这样:

Let's say i have a table named User. When I use the Entity Framework to get the records i do like this:

var db = new Context();
var users = db.Users;

它返回我表中的所有用户.好的.如果我这样做:

It return all the users in my table. OK. If i do this:

var fooUsers = db.Users.Where(u => u.Name == 'foo');

它将给我所有名称为'foo'的用户.好的.我的问题是: 实体框架进行如下查询:

It will give me all the users with name 'foo'. OK. My question is: The entity framework make a query like:

select * from user where name = 'foo'

还是加载所有用户并使用lambda表达式在服务器上过滤它们?

Or it load all the users and filter them on the server with lambda expression?

推荐答案

提交到数据库的Sql将包含where子句.您可以使用SQL Server Profiler来监视将查询提交到数据库的过程.

The Sql submitted to your database will contain your where clause. You can use SQL Server Profiler to watch as queries are submitted to your DB.

这篇关于实体框架-Where子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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