public SqlServerSnapshotQueryBuilder(SqlServerSnapshotSettings settings) { var schemaName = settings.SchemaName; var tableName = settings.TableName; _deleteSql = @"DELETE FROM {0}.{1} WHERE PersistenceId = @PersistenceId ".QuoteSchemaAndTable(schemaName, tableName); _insertSql = @"INSERT INTO {0}.{1} (PersistenceId, SequenceNr, Timestamp, Manifest, Snapshot) VALUES (@PersistenceId, @SequenceNr, @Timestamp, @Manifest, @Snapshot)".QuoteSchemaAndTable(schemaName, tableName); _selectSql = @"SELECT PersistenceId, SequenceNr, Timestamp, Manifest, Snapshot FROM {0}.{1} WHERE PersistenceId = @PersistenceId".QuoteSchemaAndTable(schemaName, tableName); }
public SqlServerSnapshotQueryBuilder(SqlServerSnapshotSettings settings) { string schemaName = settings.SchemaName; string tableName = settings.TableName; _deleteSql = @"DELETE FROM {0}.{1} WHERE PersistenceId = @PersistenceId " .QuoteSchemaAndTable(settings.SchemaName, settings.TableName); _selectSql = @"SELECT TOP 1 PersistenceId, SequenceNr, Timestamp, Manifest, Snapshot FROM {0}.{1} WHERE PersistenceId = @PersistenceId" .QuoteSchemaAndTable(schemaName, tableName); var insertSqlBuilder = new StringBuilder(); insertSqlBuilder.Append("IF (SELECT COUNT(*) FROM {0}.{1} WHERE SequenceNr = @SequenceNr AND PersistenceId = @PersistenceId) > 0 " .QuoteSchemaAndTable(schemaName, tableName)); insertSqlBuilder.Append(@"UPDATE {0}.{1} SET PersistenceId = @PersistenceId, SequenceNr = @SequenceNr, Timestamp = @Timestamp, Manifest = @Manifest, Snapshot = @Snapshot WHERE SequenceNr = @SequenceNr AND PersistenceId = @PersistenceId ELSE " .QuoteSchemaAndTable(schemaName, tableName)); insertSqlBuilder.Append(@"INSERT INTO {0}.{1} (PersistenceId, SequenceNr, Timestamp, Manifest, Snapshot) VALUES (@PersistenceId, @SequenceNr, @Timestamp, @Manifest, @Snapshot)" .QuoteSchemaAndTable(schemaName, tableName)); _insertSql = insertSqlBuilder.ToString(); }
public SqlServerSnapshotStore() : base() { _settings = SqlServerPersistence.Instance.Apply(Context.System).SnapshotStoreSettings; QueryBuilder = new DefaultSnapshotQueryBuilder(_settings.SchemaName, _settings.TableName); }