private void DropExistingTable() { using (var connection = SqlServerConnection.Create()) using (var command = new SqlCommand("IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = SCHEMA_NAME() AND TABLE_NAME = 'Snapshot') DROP TABLE [Snapshot];", connection)) { connection.Open(); command.ExecuteNonQuery(); } }
private Boolean TableExists() { using (var connection = SqlServerConnection.Create()) using (var command = new SqlCommand("SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = SCHEMA_NAME() AND TABLE_NAME = 'Snapshot';", connection)) { connection.Open(); return(Equals(command.ExecuteScalar(), 1)); } }
private Int32 CountSnapshots() { using (var connection = SqlServerConnection.Create()) using (var command = new SqlCommand("SELECT COUNT(*) FROM [Snapshot];", connection)) { connection.Open(); return((Int32)command.ExecuteScalar()); } }
private Int32 CountSnapshots(Guid streamId) { using (var connection = SqlServerConnection.Create()) using (var command = new SqlCommand("SELECT COUNT(*) FROM [Snapshot] WHERE [StreamId] = @StreamId;", connection)) { command.Parameters.AddWithValue("@StreamId", streamId); connection.Open(); return((Int32)command.ExecuteScalar()); } }