-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes command store Get where ContextKey in null
- Loading branch information
Toby Henderson
committed
Feb 22, 2019
1 parent
288238e
commit 6245248
Showing
3 changed files
with
19 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#region Licence | ||
#region Licence | ||
|
||
/* The MIT License (MIT) | ||
Copyright © 2014 Francesco Pighi <[email protected]> | ||
|
@@ -104,8 +104,7 @@ public void Add(Message message, int messageStoreTimeout = -1) | |
/// <returns>Task<Message>.</returns> | ||
public Message Get(Guid messageId, int messageStoreTimeout = -1) | ||
{ | ||
var sql = string.Format("SELECT * FROM {0} WHERE MessageId = @MessageId", | ||
_configuration.MessageStoreTableName); | ||
var sql = $"SELECT * FROM {_configuration.MessageStoreTableName} WHERE MessageId = @MessageId"; | ||
var parameters = new[] | ||
{ | ||
CreateSqlParameter("MessageId", messageId) | ||
|
@@ -163,7 +162,7 @@ public Message Get(Guid messageId, int messageStoreTimeout = -1) | |
/// <returns><see cref="Task{Message}" />.</returns> | ||
public async Task<Message> GetAsync(Guid messageId, int messageStoreTimeout = -1, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
var sql = string.Format("SELECT * FROM {0} WHERE MessageId = @MessageId", _configuration.MessageStoreTableName); | ||
var sql = $"SELECT * FROM {_configuration.MessageStoreTableName} WHERE MessageId = @MessageId"; | ||
|
||
var parameters = new[] | ||
{ | ||
|
@@ -234,7 +233,7 @@ public IList<Message> Get(int pageSize = 100, int pageNumber = 1) | |
//Fold this code back in as there is only one choice | ||
private DbParameter CreateSqlParameter(string parameterName, object value) | ||
{ | ||
return new SqlParameter(parameterName, value); | ||
return new SqlParameter(parameterName, value ?? DBNull.Value); | ||
|
||
} | ||
|
||
|
@@ -281,10 +280,7 @@ private DbConnection GetConnection() | |
private DbCommand InitAddDbCommand(DbConnection connection, DbParameter[] parameters) | ||
{ | ||
var command = connection.CreateCommand(); | ||
var sql = | ||
string.Format( | ||
"INSERT INTO {0} (MessageId, MessageType, Topic, Timestamp, HeaderBag, Body) VALUES (@MessageId, @MessageType, @Topic, @Timestamp, @HeaderBag, @Body)", | ||
_configuration.MessageStoreTableName); | ||
var sql = $"INSERT INTO {_configuration.MessageStoreTableName} (MessageId, MessageType, Topic, Timestamp, HeaderBag, Body) VALUES (@MessageId, @MessageType, @Topic, @Timestamp, @HeaderBag, @Body)"; | ||
command.CommandText = sql; | ||
command.Parameters.AddRange(parameters); | ||
return command; | ||
|
@@ -365,4 +361,4 @@ private void SetPagingCommandFor(DbCommand command, MsSqlMessageStoreConfigurati | |
command.Parameters.AddRange(parameters); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters