使用 LINQ EF 进行复杂联接
如何使用 LINQ to EF 连接两个查询?我需要返回给我的结果集,其中包括来自两个组合查询的连接数据。
1
select StockNo, Description
from VehicleOption_New
where StockNo in
(
select v.StockNo
from Vehicles v
join StatusDescription s
on v.Status = s.StatusId
where NewOrUsed = 'n' and v.model = 'cts'
)
and color is not null
2
select v.StockNo, s.StatusDescriptionText
from Vehicles v
join StatusDescription s
on v.Status = s.StatusId
where NewOrUsed = 'n' and v.model = 'cts'
How can I join the two queries using LINQ to EF? I need the result set returned to me that includes joined data from the 2 queries combined.
1
select StockNo, Description
from VehicleOption_New
where StockNo in
(
select v.StockNo
from Vehicles v
join StatusDescription s
on v.Status = s.StatusId
where NewOrUsed = 'n' and v.model = 'cts'
)
and color is not null
2
select v.StockNo, s.StatusDescriptionText
from Vehicles v
join StatusDescription s
on v.Status = s.StatusId
where NewOrUsed = 'n' and v.model = 'cts'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一旦有了等效的 EF 查询,您就可以使用
Concat()
或Union()
来合并结果。Once you have the equivalent EF queries you can use either
Concat()
orUnion()
to combine the results.