mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-11-10 19:35:09 +08:00
-
This commit is contained in:
@@ -82,6 +82,55 @@ namespace SqlSugar
|
|||||||
this.Context.EntityProvider.GetProperty<T>(identityKey).SetValue(result,setValue, null);
|
this.Context.EntityProvider.GetProperty<T>(identityKey).SetValue(result,setValue, null);
|
||||||
return idValue>0;
|
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
|
#endregion
|
||||||
|
|
||||||
#region Setting
|
#region Setting
|
||||||
@@ -276,56 +325,6 @@ namespace SqlSugar
|
|||||||
asyncInsertableBuilder.TableWithString = this.InsertBuilder.TableWithString;
|
asyncInsertableBuilder.TableWithString = this.InsertBuilder.TableWithString;
|
||||||
return asyncInsertable;
|
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
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace SqlSugar
|
|||||||
public SqlSugarClient Context { get; internal set; }
|
public SqlSugarClient Context { get; internal set; }
|
||||||
public EntityInfo EntityInfo { get; internal set; }
|
public EntityInfo EntityInfo { get; internal set; }
|
||||||
public ISqlBuilder SqlBuilder { 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 IAdo Ado { get { return Context.Ado; } }
|
||||||
public T[] UpdateObjs { get; set; }
|
public T[] UpdateObjs { get; set; }
|
||||||
public bool IsMappingTable { get { return this.Context.MappingTables != null && this.Context.MappingTables.Any(); } }
|
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");
|
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());
|
return this.Ado.ExecuteCommand(sql, UpdateBuilder.Parameters == null ? null : UpdateBuilder.Parameters.ToArray());
|
||||||
}
|
}
|
||||||
|
public Task<int> ExecuteCommandAsync() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
public IUpdateable<T> AS(string tableName)
|
public IUpdateable<T> AS(string tableName)
|
||||||
{
|
{
|
||||||
var entityName = typeof(T).Name;
|
var entityName = typeof(T).Name;
|
||||||
@@ -298,5 +301,17 @@ namespace SqlSugar
|
|||||||
this.Context.MappingTables = OldMappingTableList;
|
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>
|
public interface IUpdateable<T>
|
||||||
{
|
{
|
||||||
|
UpdateBuilder UpdateBuilder { get; set; }
|
||||||
int ExecuteCommand();
|
int ExecuteCommand();
|
||||||
|
Task<int> ExecuteCommandAsync();
|
||||||
IUpdateable<T> AS(string tableName);
|
IUpdateable<T> AS(string tableName);
|
||||||
IUpdateable<T> With(string lockString);
|
IUpdateable<T> With(string lockString);
|
||||||
IUpdateable<T> Where(bool isNoUpdateNull,bool IsOffIdentity = false);
|
IUpdateable<T> Where(bool isNoUpdateNull,bool IsOffIdentity = false);
|
||||||
|
|||||||
Reference in New Issue
Block a user