如何在linq中将此sql查询写入sql [英] How to write this sql query in linq to sql
本文介绍了如何在linq中将此sql查询写入sql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Linq中编写以下查询?
How to write below query in Linq?
select c.Name,Location from Category c
join somechildtable ct
on c.ID = ct.CategoryID
cross join Locations
谢谢。
Thanks.
推荐答案
当你的原始查询似乎错过了选择列表中Location字段的表前缀,我假设它来自Locations表。
您的LINQ查询将是:
While your original query seems to miss a table prefix for the Location field in the select list, I have assumed it comes from the Locations table.
Your LINQ query would be:
from c in Category
from l in Locations
join ct in somechildtable on c.ID equals ct.CategoryID
select c.Name, l.Location
这篇关于如何在linq中将此sql查询写入sql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文