public bool Exists(Guid command) { using (var db = new LogDbContext(DatabaseConnectionString)) { return(db.Commands .AsNoTracking() .Any(x => x.CommandIdentifier == command)); } }
public IEnumerable <Guid> GetExpired(DateTimeOffset at) { using (var db = new LogDbContext(DatabaseConnectionString)) { return(db.Aggregates .AsNoTracking() .Where(x => x.AggregateExpires != null && x.AggregateExpires <= at) .Select(x => x.AggregateIdentifier) .ToList()); } }
public IEnumerable <SerializedCommand> GetExpired(DateTimeOffset at) { using (var db = new LogDbContext(DatabaseConnectionString)) { var commands = db.Commands .AsNoTracking() .Where(x => x.SendScheduled <= at && x.SendStatus == "Scheduled") .ToArray(); return(commands); } }
public SerializedCommand Get(Guid command) { using (var db = new LogDbContext(DatabaseConnectionString)) { var entity = db.Commands .AsNoTracking() .Where(x => x.CommandIdentifier == command) .FirstOrDefault(); return(entity ?? throw new CommandNotFoundException($"Command not found: {command}")); } }
public void Delete(Guid id) { using (var db = new LogDbContext(DatabaseConnectionString)) { var command = db.Commands.FirstOrDefault(x => x.CommandIdentifier == id); if (command != null) { db.Commands.Remove(command); db.SaveChanges(); } } }