E_T

导航

ef join查询

Posted on 2017-04-18 11:04  E_T  阅读(233)  评论(0编辑  收藏  举报
            temp = temp.OrderByDescending(s => s.CreateTime).Skip((param.PageIndex - 1) * param.PageSize).Take(param.PageSize);

var result = from u in temp.ToList()
                         join t in users on u.SendUserId equals t.UserId into sendUser
                         from s in sendUser.DefaultIfEmpty()
                         select new
                         {
                             u.DiamondId,
                             CreateTime = u.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
                             u.Num,
                             IsAgenter = u.UserInfo.IsAgenter ? "" : "",
                             u.UserInfo.Name,
                             u.UserInfo.Phone,
                             Type=((Model.Enums.DiamondRecordType)u.Type).ToString(),
                             SendName=s==null?"":s.Name
                         };