基本方法 http://www.codeisbug.com/Doc/8/1170
查看详情 一对多:
var result= _adminDbContext.Queryable<T_C_Base_PublishInformation, T_C_Base_PublishInfoLookor>( (t1, t2) => new object[] { JoinType.Left, t1.Id == t2.PublishId }) .Select((t1, t2) => new T_C_Base_PublishInformation { Id = t1.Id, Title = t1.Title, PublishRange = t1.PublishRange, IsUp = t1.IsUp, IsEffective = t1.IsEffective, PublishUser = t1.PublishUser, PubulishTime = t1.PubulishTime, Attachment = t1.Attachment, Content = t1.Content, Creator = t1.Creator, CreateTime = t1.CreateTime }) .Mapper((it, cache) => { var infos = cache.Get(list => { var ids = list.Select(i => i.Id).ToList(); return _adminDbContext.Queryable<T_C_Base_PublishInformation, T_C_Base_PublishInfoLookor>((st, sc) => new object[] { JoinType.Inner,st.Id==sc.PublishId}) .Select((st, sc) => new T_C_Base_PublishInfoLookor { PublishId = st.Id, CompanyName = sc.CompanyName }).ToList(); }); /*一对多*/ //创建人 var CreateUser = _adminDbContext.Queryable<T_C_Base_PublishInfoLookor>().First(s => s.PublishId == it.Id); //it.CompanyName = CreateUser?.CompanyName ?? ""; it.Lookor = string.Join(",", infos.Where(i => i.PublishId == it.Id).ToList().Select(q => q.CompanyName).ToArray()); }) .WhereIF(!string.IsNullOrEmpty(Id), t1 => t1.Id == Id);