[英]LINQ to SQL: How to handle ambiguous column names when joining tables?
I'm going to bootstrap this question with a previous one I asked: 我打算用前一个问题引导这个问题我问:
LINQ to SQL: Multiple joins ON multiple Columns. LINQ to SQL:在多个列上进行多个连接。 Is this possible?
这可能吗?
So I have a LINQ query: 所以我有一个LINQ查询:
var query =
from t1 in myTABLE1List // List<TABLE_1>
join t2 in myTABLE1List
on new { t1.ColumnA, t1.ColumnB } equals new { t2.ColumnA, t2.ColumnB }
join t3 in myTABLE1List
on new { t2.ColumnA, t2.ColumnB } equals new { t3.ColumnA, t3.ColumnB }
select new {t1.ColumnA, t2.ColumnA, t3.ColumnA } // Duplicate Anon type 'ColumnA'
How can I resolve this? 我该如何解决这个问题?
通过显式命名匿名类型的属性
select new {t1A = t1.ColumnA, t2A = t2.ColumnA, t3A = t3.ColumnA }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.