0
我正在使用Linq to Sql獲取兩個列表,而不是使用另一個列表的聯合。他們工作正常。但我想知道是否可以在一個查詢或兩個而不是我擁有的三個查詢中完成。組合Querys
Querys是
var l = (from t in T_list1
where t.Date == DateTime.Today
select new
{
oldDate=t.OldDate,
Name=t.name,
Email=t.EmailAddress,
list2TableId=t.l2Id,
CustomerId=t.customerId
});
var l2=(from d in T_list2
from e in l1
where d.Id == e.list2TableId
select new
{
Date=d.oldDate,
CName=d.Name,
Experience=e.experience,
});
list2.Dump();
var l3 = list2.Union(list3).ToList();
我一直在尋找這個職位,但沒有工作。 Combining 2 Linq queries into 1 感謝您的輸入。
你的代碼有什麼問題,你爲什麼要改變它? –
我懷疑有些拼寫錯誤,但發佈的代碼沒什麼意義。請檢查l/l1/list1和l2/list2 –