[英]How do I select multiple tables in 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
}
使用LinqPad生成查詢並學習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
子句
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.