Sql sugar的使用
时间:2021-07-01 10:21:17
帮助过:4人阅读
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);
Sql sugar的使用
标签:ring user rem shu lis ati app ble 基本