ms sql UNION ALL到Linq查询

时间:2014-09-26 15:35:34

标签: union

我有点挣扎着LINQ Queries。我需要将下面的MS SQL查询转换为LINQ。

----工作联盟查询---

SELECT COUNT(*) 
FROM (
SELECT items  FROM table1 as t1 where t1.userid = 'john'
UNION ALL
SELECT  items FROM table2 as t2 where t2.user = 'john'
) as totalItems

--- LINQ查询下面缺少where子句---

这有效但返回错误的结果...主要是b / c我不知道在哪里放置我的WHERE CLAUSE。

var unionCount = (from x in db.table1  select new { A = x.userid, B = x.userid })
                  .Concat(from y in db.table2  select new { A = y.userid, B = y.userid }).Count();

你们可以帮忙吗?

非常感谢。

塞西

0 个答案:

没有答案