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>()
.Includes(x => x.Roles).Where(x => x.Roles.Any(z=>z.id==1))
.ToList();
db.Queryable<OperatorInfo>()
var list=db.Queryable<OperatorInfo>()
.Includes(x => x.Roles).Where(x => x.Roles.Any())
.ToList();
.ToListAsync().GetAwaiter().GetResult();
//db.Queryable<OperatorInfo>()
// .Includes(x => x.Roles.Where(z=>z.name==x.realname).ToList())
// .ToList();

View File

@ -2332,6 +2332,13 @@ namespace SqlSugar
_InitNavigat(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)
{
@ -2366,7 +2373,7 @@ namespace SqlSugar
}
RestoreMapping();
_Mapper(result);
await Task.Run(() => { _InitNavigat(result); });
await _InitNavigatAsync(result);
return result;
}