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