from records in DBContext.Table1
join history in DBContext.Table2 into recordhistory
from records in recordhistory.DefaultIfEmpty()
select (n => n);
我得到的错误是“无法将null值分配给System.Guid类型的成员,该类型是非可空值类型。”
有人可以就此提出建议吗?非常感谢你。
答案 0 :(得分:0)
假设您有一个ID属性,以下内容应该作为内部联接:
var result = DBContext.Table1
.Join(DBContext.Table2, t1 => t1.ID, t2 => t2.ID, (t1, t2) => t1);
答案 1 :(得分:0)
我猜,你提供的查询应该给出错误,说明应该指定on
语句。所以,我想它应该看起来像这样:
from records in DBContext.Table1
join history in DBContext.Table2 on records.ID equals history.ID into temp
from recordhistory in temp.DefaultIfEmpty()
select new { Record = records, History = recordhistory };