public SqlJournalWriter(IFormatter formatter, SqlCommandStore commandStore) { Ensure.NotNull(commandStore, "commandStore"); Ensure.NotNull(formatter, "formatter"); _formatter = formatter; _commandStore = commandStore; _connection = commandStore.CreateConnection(); _connection.Open(); _preparedCommand = commandStore.CreateAppendCommand(); _preparedCommand.Connection = _connection; }
public SqlJournalWriter(IFormatter formatter, SqlCommandStore commandStore) { Ensure.NotNull(commandStore, "commandStore"); Ensure.NotNull(formatter, "formatter"); _formatter = formatter; _commandStore = commandStore; _connection = commandStore.CreateConnection(); _connection.Open(); _preparedCommand = commandStore.CreateAppendCommand(); _preparedCommand.Connection = _connection; }
public void MsSqlCommandStoreWriteReadEntries() { var config = new EngineConfiguration(); var settings = config.SqlSettings; settings.ConnectionString = "Data Source=.;Initial Catalog=fish;Integrated Security=True"; settings.ProviderName = "System.Data.SqlClient"; settings.TableName = "[test-" + Guid.NewGuid() + "]"; var commandStore = new SqlCommandStore(config); commandStore.Initialize(); var formatter = new BinaryFormatter(); var writer = new SqlJournalWriter(formatter, commandStore); writer.Write(JournalEntry.Create(1UL, DateTime.Now, new ModelCreated(typeof (TestModel)))); writer.Write(JournalEntry.Create(2UL, DateTime.Now.AddSeconds(1), new AppendNumberCommand(42))); writer.Write(JournalEntry.Create(3UL, DateTime.Now.AddSeconds(2), new AppendNumberCommand(64))); foreach (var entry in commandStore.GetJournalEntriesFrom(1)) { Trace.WriteLine(entry); } writer.Dispose(); }