From 6d5c771274c039203b14e2bb9890d3ed8fd8e6dc Mon Sep 17 00:00:00 2001 From: Savorboard Date: Sun, 17 Dec 2017 20:48:06 +0800 Subject: [PATCH] fix table name prefix bug. --- src/DotNetCore.CAP.MySql/MySqlFetchedMessage.cs | 10 +++++----- src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/DotNetCore.CAP.MySql/MySqlFetchedMessage.cs b/src/DotNetCore.CAP.MySql/MySqlFetchedMessage.cs index 08ceeb4..6fb0788 100644 --- a/src/DotNetCore.CAP.MySql/MySqlFetchedMessage.cs +++ b/src/DotNetCore.CAP.MySql/MySqlFetchedMessage.cs @@ -6,14 +6,14 @@ namespace DotNetCore.CAP.MySql { public class MySqlFetchedMessage : IFetchedMessage { - private readonly string _connectionString = null; + private readonly MySqlOptions _options; - public MySqlFetchedMessage(int messageId, MessageType type, string connectionString) + public MySqlFetchedMessage(int messageId, MessageType type, MySqlOptions options) { MessageId = messageId; MessageType = type; - _connectionString = connectionString; + _options = options; } public int MessageId { get; } @@ -27,9 +27,9 @@ namespace DotNetCore.CAP.MySql public void Requeue() { - using (var connection = new MySqlConnection(_connectionString)) + using (var connection = new MySqlConnection(_options.ConnectionString)) { - connection.Execute("insert into `cap.queue`(`MessageId`,`MessageType`) values(@MessageId,@MessageType);" + connection.Execute($"insert into `{_options.TableNamePrefix}.queue`(`MessageId`,`MessageType`) values(@MessageId,@MessageType);" , new {MessageId, MessageType }); } } diff --git a/src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs b/src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs index 355f8e5..f8d678f 100644 --- a/src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs +++ b/src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs @@ -150,7 +150,7 @@ SELECT * FROM `{_prefix}.received` WHERE Id=LAST_INSERT_ID();"; if (fetchedMessage == null) return null; - return new MySqlFetchedMessage(fetchedMessage.MessageId, fetchedMessage.MessageType, Options.ConnectionString); + return new MySqlFetchedMessage(fetchedMessage.MessageId, fetchedMessage.MessageType, Options); } public void Dispose()