我正在使用linq查询,因为我有两个实体模型我无法使用左连接我用这种方式实现我得到null异常
var query = from r in ContactsContext.My_schedule_categories.Where(rp => rp.Usr_schedule_owner_usr_id == currentID)
join p in profileContext.My_schedule_categories on r.Usr_schedule_category_id equals p.sid into g
Where(pr => pr.sid == pr.catid)
from p in g.DefaultIfEmpty()
select new
{
category = r.Usr_schedule_category,
caid = r.Usr_schedule_category_id,
oid = r.Usr_schedule_owner_usr_id,
sid = p.sid
}
那么请你给我发送任何示例代码,如何将两个表连接到不同的实体模型?