排除从选择使用LINQ列 [英] Exclude a column from a select using LINQ
本文介绍了排除从选择使用LINQ列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我发展与实体框架代码优先WCF的RESTful Web服务。
I'm developing a WCF RESTful web service with Entity Framework Code First.
我有一个表用户
有很多列。我这样做是为了得到一个特定的用户:
I have a table Users
with a lot of columns. I do this to get an specific user:
context.Configuration.ProxyCreationEnabled = false;
var users = from u in context.Users
where u.UserId == userId
select u;
在这个表中,有一个密码列,我不希望返回此列。
On this table, there is a password column, and I don't want return this column.
我怎样才能排除该密码栏中选择?
推荐答案
指定你想在你的SELECT语句中的每一列:从u上下文
Specify each column that you do want in your select statement:
var users = from u in context.Users
where u.UserId == userId
select u.UserId, u.Watever, etc... ;
这篇关于排除从选择使用LINQ列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文