mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-20 18:47:35 +08:00
Add: Storageable.ExecuteReturnEntity
This commit is contained in:
@@ -151,6 +151,38 @@ namespace SqlSugar
|
|||||||
result += updateRow;
|
result += updateRow;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
public T ExecuteReturnEntity()
|
||||||
|
{
|
||||||
|
var x = this.ToStorage();
|
||||||
|
if (x.InsertList?.Any()==true)
|
||||||
|
{
|
||||||
|
var data = x.AsInsertable.ExecuteReturnEntity();
|
||||||
|
x.AsUpdateable.ExecuteCommand();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x.AsInsertable.ExecuteCommand();
|
||||||
|
x.AsUpdateable.ExecuteCommand();
|
||||||
|
return x.UpdateList.FirstOrDefault()?.Item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public async Task<T> ExecuteReturnEntityAsync()
|
||||||
|
{
|
||||||
|
var x = this.ToStorage();
|
||||||
|
if (x.InsertList.Any())
|
||||||
|
{
|
||||||
|
var data = await x.AsInsertable.ExecuteReturnEntityAsync();
|
||||||
|
await x.AsUpdateable.ExecuteCommandAsync();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await x.AsInsertable.ExecuteCommandAsync();
|
||||||
|
await x.AsUpdateable.ExecuteCommandAsync();
|
||||||
|
return x.UpdateList.FirstOrDefault()?.Item;
|
||||||
|
}
|
||||||
|
}
|
||||||
public Task<int> ExecuteCommandAsync(CancellationToken cancellationToken)
|
public Task<int> ExecuteCommandAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
this.Context.Ado.CancellationToken=cancellationToken;
|
this.Context.Ado.CancellationToken=cancellationToken;
|
||||||
|
@@ -29,6 +29,8 @@ namespace SqlSugar
|
|||||||
Task<StorageableResult<T>> ToStorageAsync();
|
Task<StorageableResult<T>> ToStorageAsync();
|
||||||
IStorageable<T> As(string tableName);
|
IStorageable<T> As(string tableName);
|
||||||
int ExecuteCommand();
|
int ExecuteCommand();
|
||||||
|
T ExecuteReturnEntity();
|
||||||
|
Task<T> ExecuteReturnEntityAsync();
|
||||||
Task<int> ExecuteCommandAsync();
|
Task<int> ExecuteCommandAsync();
|
||||||
Task<int> ExecuteCommandAsync(CancellationToken cancellationToken);
|
Task<int> ExecuteCommandAsync(CancellationToken cancellationToken);
|
||||||
int ExecuteSqlBulkCopy();
|
int ExecuteSqlBulkCopy();
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
<package >
|
<package >
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>SqlSugarCore</id>
|
<id>SqlSugarCore</id>
|
||||||
<version>5.1.4.127-preview13</version>
|
<version>5.1.4.127-preview29</version>
|
||||||
<authors>sunkaixuan</authors>
|
<authors>sunkaixuan</authors>
|
||||||
<owners>果糖大数据科技</owners>
|
<owners>果糖大数据科技</owners>
|
||||||
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
|
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
|
||||||
|
Reference in New Issue
Block a user