C#EF框架里面的 join Left Join In 写法

版权声明:本文为博主原创文章,可以转载,但是请规划转载,注明文章来源,谢谢。 https://blog.csdn.net/u010067685/article/details/77991354

记录一下而已:

Join

var query = BmpDb.UserDetails.Where(i => true);

  var queryList = from q in query
                                join u in Db.Users on q.id equals ac.Userid

                               select new{q.Name,....... }

Left join:

var query = BmpDb.UserDetails.Where(i => true);

  var queryList = from q in query
                                join ac in Db.Users on q.id equals ac.Userid into ud

                               from ud1 in ud.DefaultIfEmpty()//

                               select new{q.Name,ud1.id ....... }


Join 多条件:

var query = BmpDb.UserDetails.Where(i => true);

  var queryList = from q in query
                                join u in Db.Users on new { time = q.CTime, id= q.id } equals new { time = u.CTime, id= u.userid }
                               select new{q.Name,....... }


Not In :

 var query = db.ActivationInfos.Where(c => c.BId == packname);

            var queryList = from q in query
                            where !(from a in db.ActivationInfos where a.BId == packname  select a.UUId).Contains(q.UUId)
                            select q;


In:把上面的 ! 去掉即可

展开阅读全文

没有更多推荐了,返回首页