mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-15 20:49:31 +08:00
update sqlserver azure
This commit is contained in:
parent
0d9ae07493
commit
0d382b529f
@ -31,6 +31,7 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
internal bool IsOpenAsync { get; set; }
|
||||
protected List<IDataParameter> OutputParameters { get; set; }
|
||||
public virtual string SqlParameterKeyWord { get { return "@"; } }
|
||||
public IDbTransaction Transaction { get; set; }
|
||||
@ -626,7 +627,7 @@ namespace SqlSugar
|
||||
if (this.ProcessingEventStartingSQL != null)
|
||||
ExecuteProcessingSQL(ref sql,ref parameters);
|
||||
ExecuteBefore(sql, parameters);
|
||||
var sqlCommand = GetCommand(sql, parameters);
|
||||
var sqlCommand =IsOpenAsync? await GetCommandAsync(sql, parameters) : GetCommand(sql, parameters);
|
||||
int count;
|
||||
if (this.CancellationToken == null)
|
||||
count=await sqlCommand.ExecuteNonQueryAsync();
|
||||
@ -668,7 +669,7 @@ namespace SqlSugar
|
||||
if (this.ProcessingEventStartingSQL != null)
|
||||
ExecuteProcessingSQL(ref sql,ref parameters);
|
||||
ExecuteBefore(sql, parameters);
|
||||
var sqlCommand = GetCommand(sql, parameters);
|
||||
var sqlCommand = IsOpenAsync ? await GetCommandAsync(sql, parameters) : GetCommand(sql, parameters);
|
||||
DbDataReader sqlDataReader;
|
||||
if(this.CancellationToken==null)
|
||||
sqlDataReader=await sqlCommand.ExecuteReaderAsync(this.IsAutoClose() ? CommandBehavior.CloseConnection : CommandBehavior.Default);
|
||||
@ -707,7 +708,7 @@ namespace SqlSugar
|
||||
if (this.ProcessingEventStartingSQL != null)
|
||||
ExecuteProcessingSQL(ref sql,ref parameters);
|
||||
ExecuteBefore(sql, parameters);
|
||||
var sqlCommand = GetCommand(sql, parameters);
|
||||
var sqlCommand = IsOpenAsync ? await GetCommandAsync(sql, parameters) : GetCommand(sql, parameters);
|
||||
object scalar;
|
||||
if(CancellationToken==null)
|
||||
scalar=await sqlCommand.ExecuteScalarAsync();
|
||||
@ -1461,6 +1462,11 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Helper
|
||||
public virtual async Task<DbCommand> GetCommandAsync(string sql, SugarParameter[] parameters)
|
||||
{
|
||||
await Task.FromResult(0);
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public async Task CloseAsync()
|
||||
{
|
||||
if (this.Transaction != null)
|
||||
|
@ -7,12 +7,16 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using System.Threading;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public class SqlServerProvider : AdoProvider
|
||||
{
|
||||
public SqlServerProvider() { }
|
||||
|
||||
public SqlServerProvider() {
|
||||
this.IsOpenAsync = true;
|
||||
}
|
||||
public override IDbConnection Connection
|
||||
{
|
||||
get
|
||||
@ -75,6 +79,23 @@ namespace SqlSugar
|
||||
CheckConnection();
|
||||
return sqlCommand;
|
||||
}
|
||||
public override async Task<DbCommand> GetCommandAsync(string sql, SugarParameter[] parameters)
|
||||
{
|
||||
SqlCommand sqlCommand = new SqlCommand(sql, (SqlConnection)this.Connection);
|
||||
sqlCommand.CommandType = this.CommandType;
|
||||
sqlCommand.CommandTimeout = this.CommandTimeOut;
|
||||
if (this.Transaction != null)
|
||||
{
|
||||
sqlCommand.Transaction = (SqlTransaction)this.Transaction;
|
||||
}
|
||||
if (parameters.HasValue())
|
||||
{
|
||||
SqlParameter[] ipars = GetSqlParameter(parameters);
|
||||
sqlCommand.Parameters.AddRange(ipars);
|
||||
}
|
||||
await CheckConnectionAsync();
|
||||
return sqlCommand;
|
||||
}
|
||||
public override void SetCommandToAdapter(IDataAdapter dataAdapter, DbCommand command)
|
||||
{
|
||||
((SqlDataAdapter)dataAdapter).SelectCommand = (SqlCommand)command;
|
||||
|
Loading…
Reference in New Issue
Block a user