LINQ代码等效于TSQL查询 [英] LINQ Code equivalent of a TSQL query
本文介绍了LINQ代码等效于TSQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我想要一个与之等效的linq代码:
Hi
I want a linq code equivalent of this:
Select Company.Name,
Person.Name
From Person, Company
Where Company.PersonID = Person.ID And
Company.City = N"Bolton"
实体名称:Company,Person
Entity names: Company, Person
推荐答案
尝试此代码
try this Code
var QueryResult = from p in Person
join c in Company on p.ID equals c.PersonID
where c.City == N"Bolton"
select new { c.Name, p.Name };
单击此处了解更多信息
投票或接受解决方案
如果这对您有帮助
谢谢
Click here for more information
Vote or Accept solution
If this will help you
thanks
使用 Linqer [
Use Linqer [^] tool to translate any SQL statement to LINQ.
哇-太简单了.像
Wow - that''s pretty trivial. Something like
from c in categories
join p in products on c equals p.Category into ps
select new { Category = c, Products = ps };
这是来自以下站点的示例.您应该能够转换此语法以适合您的要求.
http://msdn.microsoft.com/en-us/vstudio/aa336746 [ ^ ]
That is a sample from the site below. You should be able to convert this syntax to suit your requirements.
http://msdn.microsoft.com/en-us/vstudio/aa336746[^]
这篇关于LINQ代码等效于TSQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文