使用 linq 合并两个表
我有两个 linq - sql 查询,我想知道如何加入它们。
第一个查询
var ab = from a in Items_worker.getCEAItems()
where a.ProjectCode == lbl_projectCode.Text
select new
{
a.ID
};
第二个查询
var j = from c in tblInc_worker.get(c => c.MarginID == MarginID && c.IncTypeID == "CAPEX")
orderby c.DateCreated
select c.ID;
第一个查询将返回:
fasf-1212-1212-1212-1212
afaa-1414-1414-1414-1414
第二个查询将返回:
fasf -1212-1212-1212-1212
afaa-1414-1414-1414-1414
0000-0000-0000-0000-0000
1111-1111-1111-1111-1111
问题是我如何连接这两个表。其中第二个查询应返回第一个查询中找到的具有相同 ID 的所有记录,加上第二个查询中包含“0000-0000-0000-0000-0000”的 id。
结果应为:
fasf-1212-1212-1212 -1212
afaa-1414-1414-1414-1414
0000-0000-0000-0000-0000
i have two linq - sql queries, and im wondering how to join them..
First Query
var ab = from a in Items_worker.getCEAItems()
where a.ProjectCode == lbl_projectCode.Text
select new
{
a.ID
};
Second Query
var j = from c in tblInc_worker.get(c => c.MarginID == MarginID && c.IncTypeID == "CAPEX")
orderby c.DateCreated
select c.ID;
First Query would return:
fasf-1212-1212-1212-1212
afaa-1414-1414-1414-1414
Second Query would return:
fasf-1212-1212-1212-1212
afaa-1414-1414-1414-1414
0000-0000-0000-0000-0000
1111-1111-1111-1111-1111
question is how can i possibly join the two table. Wherein the second query should return all of the records with the same ID found in the first query plus the id containing "0000-0000-0000-0000-0000" second query..
The result should be:
fasf-1212-1212-1212-1212
afaa-1414-1414-1414-1414
0000-0000-0000-0000-0000
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 union 来连接两个查询,例如将第二个查询分成两部分,条件如下:
希望这有帮助..
You can use union to join the both queries, for example split your second query in two with conditions like :
Hope this helps..