mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-03 20:27:56 +08:00
Synchronization code
This commit is contained in:
parent
aee9dd5102
commit
d5d44b4475
@ -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();
|
||||||
|
Loading…
Reference in New Issue
Block a user