private void ConfigureEventLog(ModelBuilder modelBuilder) { modelBuilder.HasPostgresExtension("uuid-ossp"); modelBuilder.HasDbFunction(() => PostgresFunctions.CurrentTransactionIdsSnapshot()); modelBuilder.HasDbFunction(() => PostgresFunctions.SnapshotMinimalTransactionId(default));
private long?GetLastOffset() { using var context = dbContextCreator.Create(); var entityTypeName = context.Model.FindEntityType(typeof(TEntity))?.GetTableName(); Expression <Func <SqlEventLogEntry, bool> > filter = e => e.EntityType == entityTypeName && e.TransactionId < PostgresFunctions.SnapshotMinimalTransactionId(PostgresFunctions.CurrentTransactionIdsSnapshot()); if (!context.Set <SqlEventLogEntry>().Any(filter)) { return(null); } return(context.Set <SqlEventLogEntry>().Where(filter).Max(e => e.Offset)); }
private Expression <Func <SqlEventLogEntry, bool> > BuildEventsSearchCriterion(long?fromOffsetExclusive) { Expression <Func <SqlEventLogEntry, bool> > searchCriterion; if (fromOffsetExclusive.HasValue) { searchCriterion = e => e.Offset > fromOffsetExclusive.Value && e.EntityType == entityTypeName && e.TransactionId < PostgresFunctions.SnapshotMinimalTransactionId(PostgresFunctions.CurrentTransactionIdsSnapshot()); } else { searchCriterion = e => e.EntityType == entityTypeName && e.TransactionId < PostgresFunctions.SnapshotMinimalTransactionId(PostgresFunctions.CurrentTransactionIdsSnapshot()); } return(searchCriterion); }