我有这段代码
var result = (from row1 in table.AsEnumerable()
join row2 in tabelPopup.AsEnumerable()
on row1.Field<string>("CallID") equals
row2.Field<string>("callID")
where row1.Field<string>("Direction") == "I"
select new
{
Agent = row1.Field<string>("Agent"),
StartTime = row1.Field<string>("StartTime"),
Reason = row2.Field<string>("Reason")
});
其中table
和tablePopup
是数据表,
如你所见,我正在加入。我想做一个左联盟,你可以帮助我plesae吗?
我经常阅读,但我发现我必须执行join
和into
,然后使用into name
函数执行.DefaultOfEmpty()
,但我不能
答案 0 :(得分:0)
var left_outer_join =
from row1 in table.AsEnumerable()
join row2 in tabelPopup.AsEnumerable()
on row1.Field<string>("CallID") equals row2.Field<string>("callID")
into outJoin
where row1.Field<string>("Direction") == "I"
from oj in outJoin.DefaultIfEmpty()
select new {
Agent = row1.Field<string>("Agent"),
StartTime = row1.Field<string>("StartTime"),
Reason = (oj == null)
? String.Empty
: oj.Field<string>("Reason")
};