如何改变这个"选择"进入Lambda表达式

时间:2014-09-03 18:46:48

标签: c# sql lambda

有谁知道如何转换以下内容"选择"进入lambda表达式?

SELECT * FROM table1 WHERE OID IN (SELECT OIDPhone FROM table2 WHERE city = 'New York')

1 个答案:

答案 0 :(得分:2)

你可以这样做:

var subQuery = db.OIDPhone.Where(r=> r.City == "New York").Select(r=> r.OIDPhone);
var finalQuery = db.Table1.Where(r=> subQuery.Contains(r.OID));