select top 10 JobId,Title,
(SELECT TOP 1 Authorized FROM Company WHERE CompanyId=Job.CompanyId) as CompanyName
from Job
如何在“LINQ”中创建这个sql代码?
答案 0 :(得分:0)
您可以尝试类似
的内容foreach (Variety variety in varieties.ToList())
{
if (variety.Type != main.Type && variety.Type != null)
{
varieties.Remove(variety);
}
}
假设您将至少拥有一家公司,否则您可能必须使用var query = (from j in job
select new
{
j.JobId,
j.Title,
CompanyName = (from c in from Company
where c.CompanyId=j.CompanyId)
select c.Authorized ).First()
}
).Take(10);
。