mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-29 01:47:06 +08:00
-
This commit is contained in:
parent
d955014b02
commit
09e37a23ad
@ -82,6 +82,55 @@ namespace SqlSugar
|
||||
this.Context.EntityProvider.GetProperty<T>(identityKey).SetValue(result,setValue, null);
|
||||
return idValue>0;
|
||||
}
|
||||
public Task<int> ExecuteCommandAsync()
|
||||
{
|
||||
Task<int> result = new Task<int>(() =>
|
||||
{
|
||||
IInsertable<T> asyncInsertable = CopyInsertable();
|
||||
return asyncInsertable.ExecuteCommand();
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
public Task<int> ExecuteReturnIdentityAsync()
|
||||
{
|
||||
Task<int> result = new Task<int>(() =>
|
||||
{
|
||||
IInsertable<T> asyncInsertable = CopyInsertable();
|
||||
return asyncInsertable.ExecuteReturnIdentity();
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
public Task<T> ExecuteReturnEntityAsync()
|
||||
{
|
||||
Task<T> result = new Task<T>(() =>
|
||||
{
|
||||
IInsertable<T> asyncInsertable = CopyInsertable();
|
||||
return asyncInsertable.ExecuteReturnEntity();
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
public Task<bool> ExecuteCommandIdentityIntoEntityAsync()
|
||||
{
|
||||
Task<bool> result = new Task<bool>(() =>
|
||||
{
|
||||
IInsertable<T> asyncInsertable = CopyInsertable();
|
||||
return asyncInsertable.ExecuteCommandIdentityIntoEntity();
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
public Task<long> ExecuteReturnBigIdentityAsync()
|
||||
{
|
||||
Task<long> result = new Task<long>(() =>
|
||||
{
|
||||
IInsertable<T> asyncInsertable = CopyInsertable();
|
||||
return asyncInsertable.ExecuteReturnBigIdentity();
|
||||
});
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Setting
|
||||
@ -276,56 +325,6 @@ namespace SqlSugar
|
||||
asyncInsertableBuilder.TableWithString = this.InsertBuilder.TableWithString;
|
||||
return asyncInsertable;
|
||||
}
|
||||
|
||||
public Task<int> ExecuteCommandAsync()
|
||||
{
|
||||
Task<int> result = new Task<int>(() =>
|
||||
{
|
||||
IInsertable<T> asyncInsertable = CopyInsertable();
|
||||
return asyncInsertable.ExecuteCommand();
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
public Task<int> ExecuteReturnIdentityAsync()
|
||||
{
|
||||
Task<int> result = new Task<int>(() =>
|
||||
{
|
||||
IInsertable<T> asyncInsertable = CopyInsertable();
|
||||
return asyncInsertable.ExecuteReturnIdentity();
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
public Task<T> ExecuteReturnEntityAsync()
|
||||
{
|
||||
Task<T> result = new Task<T>(() =>
|
||||
{
|
||||
IInsertable<T> asyncInsertable = CopyInsertable();
|
||||
return asyncInsertable.ExecuteReturnEntity();
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
public Task<bool> ExecuteCommandIdentityIntoEntityAsync()
|
||||
{
|
||||
Task<bool> result = new Task<bool>(() =>
|
||||
{
|
||||
IInsertable<T> asyncInsertable = CopyInsertable();
|
||||
return asyncInsertable.ExecuteCommandIdentityIntoEntity();
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
public Task<long> ExecuteReturnBigIdentityAsync()
|
||||
{
|
||||
Task<long> result = new Task<long>(() =>
|
||||
{
|
||||
IInsertable<T> asyncInsertable = CopyInsertable();
|
||||
return asyncInsertable.ExecuteReturnBigIdentity();
|
||||
});
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ namespace SqlSugar
|
||||
public SqlSugarClient Context { get; internal set; }
|
||||
public EntityInfo EntityInfo { get; internal set; }
|
||||
public ISqlBuilder SqlBuilder { get; internal set; }
|
||||
public UpdateBuilder UpdateBuilder { get; internal set; }
|
||||
public UpdateBuilder UpdateBuilder { get; set; }
|
||||
public IAdo Ado { get { return Context.Ado; } }
|
||||
public T[] UpdateObjs { get; set; }
|
||||
public bool IsMappingTable { get { return this.Context.MappingTables != null && this.Context.MappingTables.Any(); } }
|
||||
@ -33,6 +33,9 @@ namespace SqlSugar
|
||||
Check.Exception(UpdateBuilder.WhereValues.IsNullOrEmpty() && GetPrimaryKeys().IsNullOrEmpty(), "You cannot have no primary key and no conditions");
|
||||
return this.Ado.ExecuteCommand(sql, UpdateBuilder.Parameters == null ? null : UpdateBuilder.Parameters.ToArray());
|
||||
}
|
||||
public Task<int> ExecuteCommandAsync() {
|
||||
return null;
|
||||
}
|
||||
public IUpdateable<T> AS(string tableName)
|
||||
{
|
||||
var entityName = typeof(T).Name;
|
||||
@ -298,5 +301,17 @@ namespace SqlSugar
|
||||
this.Context.MappingTables = OldMappingTableList;
|
||||
}
|
||||
}
|
||||
private IUpdateable<T> CopyUpdateable()
|
||||
{
|
||||
var asyncContext = this.Context.CopyContext(this.Context.RewritableMethods.TranslateCopy(this.Context.CurrentConnectionConfig));
|
||||
asyncContext.CurrentConnectionConfig.IsAutoCloseConnection = true;
|
||||
asyncContext.Ado.IsEnableLogEvent = this.Context.Ado.IsEnableLogEvent;
|
||||
asyncContext.Ado.LogEventStarting = this.Context.Ado.LogEventStarting;
|
||||
asyncContext.Ado.LogEventCompleted = this.Context.Ado.LogEventCompleted;
|
||||
asyncContext.Ado.ProcessingEventStartingSQL = this.Context.Ado.ProcessingEventStartingSQL;
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,9 @@ namespace SqlSugar
|
||||
{
|
||||
public interface IUpdateable<T>
|
||||
{
|
||||
UpdateBuilder UpdateBuilder { get; set; }
|
||||
int ExecuteCommand();
|
||||
Task<int> ExecuteCommandAsync();
|
||||
IUpdateable<T> AS(string tableName);
|
||||
IUpdateable<T> With(string lockString);
|
||||
IUpdateable<T> Where(bool isNoUpdateNull,bool IsOffIdentity = false);
|
||||
|
Loading…
Reference in New Issue
Block a user