Ncqrs.Eventing.Storage.SQL.MsSqlServerEventStore.SaveEvent C# (CSharp) Method

SaveEvent() private method

Saves the event to the data store.
private SaveEvent ( ISourcedEvent evnt, SqlTransaction transaction ) : void
evnt ISourcedEvent The event to save.
transaction System.Data.SqlClient.SqlTransaction The transaction.
return void
        private void SaveEvent(ISourcedEvent evnt, SqlTransaction transaction)
        {
            Contract.Requires<ArgumentNullException>(evnt != null, "The argument evnt could not be null.");
            Contract.Requires<ArgumentNullException>(transaction != null, "The argument transaction could not be null.");

            var bag = _converter.Convert(evnt);
            byte[] data = ToBinary(bag);

            using (var command = new SqlCommand(InsertNewEventQuery, transaction.Connection))
            {
                command.Transaction = transaction;
                command.Parameters.AddWithValue("EventId", evnt.EventIdentifier);
                command.Parameters.AddWithValue("EventSourceId", evnt.EventSourceId);
                command.Parameters.AddWithValue("Name", evnt.GetType().FullName);
                command.Parameters.AddWithValue("Sequence", evnt.EventSequence);
                command.Parameters.AddWithValue("Data", data);
                command.ExecuteNonQuery();
            }
        }