Synchronization code

This commit is contained in:
sunkaixuan 2023-12-18 11:36:43 +08:00
parent efd5596c89
commit a657925567
3 changed files with 25 additions and 6 deletions

View File

@ -370,17 +370,31 @@ namespace SqlSugar
public T ExecuteReturnEntity(bool isIncludesAllFirstLayer)
{
var data = ExecuteReturnEntity();
return this.Context.Queryable<T>().WhereClassByPrimaryKey(data).IncludesAllFirstLayer().First();
if (this.InsertBuilder.IsWithAttr)
{
return this.Context.Root.QueryableWithAttr<T>().WhereClassByPrimaryKey(data).IncludesAllFirstLayer().First();
}
else
{
return this.Context.Queryable<T>().WhereClassByPrimaryKey(data).IncludesAllFirstLayer().First();
}
}
public async Task<T> ExecuteReturnEntityAsync()
{
await ExecuteCommandIdentityIntoEntityAsync();
return InsertObjs.First();
}
public async Task<T> ExecuteReturnEntityAsync(bool isIncludesAllFirstLayer)
public async Task<T> ExecuteReturnEntityAsync(bool isIncludesAllFirstLayer)
{
var data=await ExecuteReturnEntityAsync();
return await this.Context.Queryable<T>().WhereClassByPrimaryKey(data).IncludesAllFirstLayer().FirstAsync();
var data = await ExecuteReturnEntityAsync();
if (this.InsertBuilder.IsWithAttr)
{
return await this.Context.Root.QueryableWithAttr<T>().WhereClassByPrimaryKey(data).IncludesAllFirstLayer().FirstAsync();
}
else
{
return await this.Context.Queryable<T>().WhereClassByPrimaryKey(data).IncludesAllFirstLayer().FirstAsync();
}
}
public async Task<bool> ExecuteCommandIdentityIntoEntityAsync()
{

View File

@ -132,6 +132,7 @@ namespace SqlSugar
}
public bool MySqlIgnore { get; internal set; }
public bool IsWithAttr { get; internal set; }
public virtual ExpressionResult GetExpressionValue(Expression expression, ResolveExpressType resolveType)
{

View File

@ -1546,11 +1546,15 @@ namespace SqlSugar
}
public IInsertable<T> InsertableWithAttr<T>(T insertObj) where T : class, new()
{
return this.GetConnectionWithAttr<T>().Insertable(insertObj);
var result= this.GetConnectionWithAttr<T>().Insertable(insertObj);
result.InsertBuilder.IsWithAttr = true;
return result;
}
public IInsertable<T> InsertableWithAttr<T>(List<T> insertObjs) where T : class, new()
{
return this.GetConnectionWithAttr<T>().Insertable(insertObjs);
var result= this.GetConnectionWithAttr<T>().Insertable(insertObjs);
result.InsertBuilder.IsWithAttr = true;
return result;
}
public IUpdateable<T> UpdateableWithAttr<T>(T updateObj) where T : class, new()
{