1

我正在使用 linq 查询,因为我有两个实体模型我无法使用左连接我以这种方式实现了我得到空异常

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
            }

那么您能否向我发送任何示例代码,我如何才能离开两个具有不同实体模型的表?

4

0 回答 0