public ArchiveStorage(IServiceProvider serviceProvider, ISerializer serializer, StorageConfig config) { logger = serviceProvider.GetService <ILogger <ArchiveStorage <PrimaryKey, StateType> > >(); this.serializer = serializer; this.config = config; var tableName = config.SnapshotArchiveTable; deleteSql = $"DELETE FROM {tableName} where id=@Id"; deleteAllSql = $"DELETE FROM {tableName} where stateid=@StateId"; getByIdSql = $"select * FROM {tableName} where id=@Id"; getListByStateIdSql = $"select Id,StartVersion,EndVersion,StartTimestamp,EndTimestamp,Index,EventIsCleared FROM {tableName} where stateid=@StateId"; getLatestByStateIdSql = $"select Id,StartVersion,EndVersion,StartTimestamp,EndTimestamp,Index,EventIsCleared FROM {tableName} where stateid=@StateId order by index desc limit 1"; insertSql = $"INSERT into {tableName}(Id,stateid,StartVersion,EndVersion,StartTimestamp,EndTimestamp,Index,EventIsCleared,data,IsOver,Version)VALUES(@Id,@StateId,@StartVersion,@EndVersion,@StartTimestamp,@EndTimestamp,@Index,@EventIsCleared,(@Data)::jsonb,@IsOver,@Version)"; updateOverSql = $"update {tableName} set IsOver=@IsOver where stateid=@StateId"; updateEventIsClearSql = $"update {tableName} set EventIsCleared=true where id=@Id"; }
public TableRepository(StorageConfig storageConfig) { this.storageConfig = storageConfig; }