[英]LINQ to SQL: How to handle ambiguous column names when joining tables?
我打算用前一個問題引導這個問題我問:
LINQ to SQL:在多個列上進行多個連接。 這可能嗎?
所以我有一個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'
我該如何解決這個問題?
通過顯式命名匿名類型的屬性
select new {t1A = t1.ColumnA, t2A = t2.ColumnA, t3A = t3.ColumnA }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.