Code optimization

This commit is contained in:
sunkaixuan 2022-04-27 20:53:24 +08:00
parent 31743774d7
commit eeecca7ba2
2 changed files with 10 additions and 3 deletions

View File

@ -38,9 +38,9 @@ namespace OrmTest
db.Queryable<OperatorInfo>() db.Queryable<OperatorInfo>()
.Includes(x => x.Roles).Where(x => x.Roles.Any(z=>z.id==1)) .Includes(x => x.Roles).Where(x => x.Roles.Any(z=>z.id==1))
.ToList(); .ToList();
db.Queryable<OperatorInfo>() var list=db.Queryable<OperatorInfo>()
.Includes(x => x.Roles).Where(x => x.Roles.Any()) .Includes(x => x.Roles).Where(x => x.Roles.Any())
.ToList(); .ToListAsync().GetAwaiter().GetResult();
//db.Queryable<OperatorInfo>() //db.Queryable<OperatorInfo>()
// .Includes(x => x.Roles.Where(z=>z.name==x.realname).ToList()) // .Includes(x => x.Roles.Where(z=>z.name==x.realname).ToList())
// .ToList(); // .ToList();

View File

@ -2332,6 +2332,13 @@ namespace SqlSugar
_InitNavigat(result); _InitNavigat(result);
return result; return result;
} }
private async Task _InitNavigatAsync<TResult>(List<TResult> result)
{
if (this.QueryBuilder.Includes != null)
{
await Task.Run(() => { _InitNavigat(result); });
}
}
private void _InitNavigat<TResult>(List<TResult> result) private void _InitNavigat<TResult>(List<TResult> result)
{ {
@ -2366,7 +2373,7 @@ namespace SqlSugar
} }
RestoreMapping(); RestoreMapping();
_Mapper(result); _Mapper(result);
await Task.Run(() => { _InitNavigat(result); }); await _InitNavigatAsync(result);
return result; return result;
} }