开发者

How to rewrite sql query below to linq to entity query?

SELECT COUNT(*)
FROM dbo.Table WITH (NOLOCK)
WHERE 
 Columnn1 IN (1,2) AND
 开发者_如何转开发Column2 IN 
  (SELECT id FROM dbo.Table2 WHERE id2 = 5 AND id3 = 1) AND
 id4 = 8


Context.Table.Count<TableObject>(t => t.id4 == 8 &&
                                      (t.Column1 == 1 || t.Column1 == 2) &&
                                      Context.Table2.Count<Table2Object>(t2 => t2.id2 == 5 && t2.id3 == 1 && t2.id == t.id) > 0);

where TableObject and Table2Object are whatever you named the entities coming from Table and Table2, respectively.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜