sql parameters cleared after executing the command
This commit is contained in:
@@ -39,6 +39,8 @@
|
||||
sqlCommand.Parameters.AddRange(command.Parameters);
|
||||
|
||||
rowsAffected = sqlCommand.ExecuteNonQuery();
|
||||
|
||||
sqlCommand.Parameters.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +64,8 @@
|
||||
|
||||
using (FluentSQLReader sqlReader = sqlCommand.ExecuteReader(CommandBehavior.SequentialAccess))
|
||||
{
|
||||
sqlCommand.Parameters.Clear();
|
||||
|
||||
while (sqlReader.Read())
|
||||
{
|
||||
yield return expression(sqlReader);
|
||||
@@ -90,6 +94,8 @@
|
||||
|
||||
var scalarObject = sqlCommand.ExecuteScalar();
|
||||
|
||||
sqlCommand.Parameters.Clear();
|
||||
|
||||
if (scalarObject is T scalarValue)
|
||||
{
|
||||
scalarResult = scalarValue;
|
||||
|
||||
@@ -10,19 +10,19 @@
|
||||
public class FluentSQLCommand : IFluentSQLCommand
|
||||
{
|
||||
private readonly FluentSQL fluentSql;
|
||||
private readonly ICollection<SqlParameter> parameters;
|
||||
private readonly IDictionary<string, SqlParameter> parameters;
|
||||
|
||||
public FluentSQLCommand(FluentSQL fluentSql, string commandText)
|
||||
{
|
||||
this.fluentSql = fluentSql.EnsureNotNull();
|
||||
this.CommandText = commandText.EnsureNotNullOrWhiteSpace();
|
||||
this.parameters = new List<SqlParameter>();
|
||||
this.parameters = new Dictionary<string, SqlParameter>();
|
||||
}
|
||||
|
||||
internal string CommandText { get; }
|
||||
|
||||
internal SqlParameter[] Parameters
|
||||
=> this.parameters.ToArray();
|
||||
=> this.parameters.Values.ToArray();
|
||||
|
||||
public int ExecuteNonQuery()
|
||||
=> this.fluentSql.ExecuteNonQuery(this);
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
var parameter = new SqlParameter(name, value);
|
||||
|
||||
this.parameters.Add(parameter);
|
||||
this.parameters[name] = parameter;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user