C# 如何在LINQ中选择多个表?
在SQL中,我有:C# 如何在LINQ中选择多个表?,c#,.net,sql,wpf,linq,C#,.net,Sql,Wpf,Linq,在SQL中,我有: SELECT gu.*, cu.* FROM [gene_genunit] as gu, [cont_unitati] as cu WHERE gu.COD_UNIT = cu.COD_UNIT 我有一个WPF应用程序。LINQ等效程序是 from gu in context.Gene join cu in Context.Cont on gu.Code_Unit equals cu.Code_Unit select new { gu, cu } 用于
SELECT gu.*, cu.*
FROM [gene_genunit] as gu, [cont_unitati] as cu
WHERE gu.COD_UNIT = cu.COD_UNIT
我有一个WPF应用程序。LINQ等效程序是
from gu in context.Gene
join cu in Context.Cont
on gu.Code_Unit equals cu.Code_Unit
select new
{
gu,
cu
}
用于生成查询和学习Linq
ARHIEntities ARHModel = new ARHIEntities(); // ARHIEntities is the model name
var qry = from gu in ARHModel.gene_genunit
from cu in ARHModel.cont_unitati
where gu.COD_UNIT == cu.COD_UNIT
select new { cu, gu };
编辑:添加了一个
where
子句你说的“它没有提到“FROM子句”是什么意思?@Misi忽略了我对FROM子句的评论。看看代码,这是一个交叉连接,与sql中的左连接不同。