Skip to content

Commit

Permalink
Dispose SqlCommandBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Hoppe committed Jun 27, 2016
1 parent ec2ca72 commit 8a7b358
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
11 changes: 6 additions & 5 deletions src/NServiceBus.SqlServer/SqlServerMessageSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,13 @@ public void Send(TransportMessage message, Address address)

static string SendSqlCommandText(string schemaName, Address address)
{
var sanitizer = new SqlCommandBuilder();

var quotedSchema = sanitizer.QuoteIdentifier(schemaName);
var quotedTable = sanitizer.QuoteIdentifier(TableNameUtils.GetTableName(address));
using (var sanitizer = new SqlCommandBuilder())
{
var quotedSchema = sanitizer.QuoteIdentifier(schemaName);
var quotedTable = sanitizer.QuoteIdentifier(TableNameUtils.GetTableName(address));

return string.Format(SqlSend, quotedSchema, quotedTable);
return string.Format(SqlSend, quotedSchema, quotedTable);
}
}

private static void ThrowFailedToSendException(Address address, Exception ex)
Expand Down
9 changes: 5 additions & 4 deletions src/NServiceBus.SqlServer/SqlServerPollingDequeueStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ public void Init(Address address, TransactionSettings transactionSettings,
Timeout = transactionSettings.TransactionTimeout
};

var sanitizer = new SqlCommandBuilder();

quotedSchemaName = sanitizer.QuoteIdentifier(SchemaName);
quotedTableName = sanitizer.QuoteIdentifier(TableNameUtils.GetTableName(address));
using (var sanitizer = new SqlCommandBuilder())
{
quotedSchemaName = sanitizer.QuoteIdentifier(SchemaName);
quotedTableName = sanitizer.QuoteIdentifier(TableNameUtils.GetTableName(address));
}

sql = string.Format(SqlReceive, quotedSchemaName, quotedTableName);

Expand Down

0 comments on commit 8a7b358

Please sign in to comment.