1
IQueryable<v_Search> query = from pd in context.v_Search select pd;
IQueryable<t_HistoricAccountImport> xschistory = from pd in context.t_HistoricAccountImport select pd;
query = query.Where(x => names.Any(y => x.insured_name.Contains(y)));
xschistory = xschistory.Where(xsc => names.Any(y => xsc.insured_name.Contains(y)));
兩個實體出現在同樣的情況下如何合併C#中兩個不同實體的結果?
現在,當我嘗試下面的代碼結合兩種結果,通過工會或concat,這個犯規發生。
嘗試1)
var results = query.concat(xschistory); //Caused error
var result1 = query.union(xschistory); //this also throws error
我也試圖從具有類似的數據類型和值的實體選擇列,並試圖合併,
嘗試2)
var res1 = query.ToList().Select
(x => new
{ x.insured_name ,
x.ReferenceNum
});
var res2 = xschistory.ToList().Select
(y=> new
{
y.insured_name,
y.program_id
});
var finalResults = res1.Union(res2); //Still got Error
反正是有完成這個?
我相信他們需要有相同數量的列。 –
錯誤是什麼? – Martin
@ Martin,錯誤是IQueryable不包含union定義和最佳擴展方法重載'System.linq.parellelEnumerable.Union '(System.linq.parellelquery
sujai