From 4e6922e5150438240bfccfdcbaf2646ceb1ded90 Mon Sep 17 00:00:00 2001 From: James Bradt Date: Wed, 27 Oct 2010 15:03:39 -0400 Subject: [PATCH] Convert SQL Storage to using clob for event data instead of blob --- .../src/Ncqrs/Eventing/Storage/SQL/MsSqlServerEventStore.cs | 5 ++--- .../src/Ncqrs/Eventing/Storage/SQL/TableCreationScript.sql | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Framework/src/Ncqrs/Eventing/Storage/SQL/MsSqlServerEventStore.cs b/Framework/src/Ncqrs/Eventing/Storage/SQL/MsSqlServerEventStore.cs index 3731fcac..4339e30a 100644 --- a/Framework/src/Ncqrs/Eventing/Storage/SQL/MsSqlServerEventStore.cs +++ b/Framework/src/Ncqrs/Eventing/Storage/SQL/MsSqlServerEventStore.cs @@ -279,7 +279,7 @@ private StoredEvent ReadEvent(SqlDataReader reader) var eventVersion = Version.Parse((string)reader["Version"]); var eventSourceId = (Guid)reader["EventSourceId"]; var eventSequence = (long)reader["Sequence"]; - var data = Encoding.UTF8.GetString((Byte[])reader["Data"]); + var data = (String)reader["Data"]; return new StoredEvent( eventIdentifier, @@ -321,7 +321,6 @@ private void SaveEvent(ISourcedEvent evnt, SqlTransaction transaction) var document = _formatter.Serialize(evnt); var raw = _translator.TranslateToRaw(document); - var data = Encoding.UTF8.GetBytes(raw.Data); using (var command = new SqlCommand(Queries.InsertNewEventQuery, transaction.Connection)) { @@ -332,7 +331,7 @@ private void SaveEvent(ISourcedEvent evnt, SqlTransaction transaction) command.Parameters.AddWithValue("Name", raw.EventName); command.Parameters.AddWithValue("Version", raw.EventVersion.ToString()); command.Parameters.AddWithValue("Sequence", raw.EventSequence); - command.Parameters.AddWithValue("Data", data); + command.Parameters.AddWithValue("Data", raw.Data); command.ExecuteNonQuery(); } } diff --git a/Framework/src/Ncqrs/Eventing/Storage/SQL/TableCreationScript.sql b/Framework/src/Ncqrs/Eventing/Storage/SQL/TableCreationScript.sql index a57bae0d..e0b7d749 100644 --- a/Framework/src/Ncqrs/Eventing/Storage/SQL/TableCreationScript.sql +++ b/Framework/src/Ncqrs/Eventing/Storage/SQL/TableCreationScript.sql @@ -9,7 +9,7 @@ [EventSourceId] [uniqueidentifier] NOT NULL, [Sequence] [bigint], - [Data] [varbinary](max) NOT NULL + [Data] [nvarchar](max) NOT NULL ) ON [PRIMARY] GO