using ColdMint.scripts.database.gameDbTables; using Microsoft.EntityFrameworkCore; namespace ColdMint.scripts.database; /// /// Game database /// 游戏数据库 /// public class GameDbContext(DbContextOptions options) : DbContext(options) { public DbSet ErrorRecords { get; set; } /// /// Async add error record /// 异步添加错误信息 /// /// public async void AddOrUpdateErrorRecordAsync(ErrorRecord errorRecord) { if (errorRecord.Message == null) { return; } var oldErrorRecord = await ErrorRecords.FindAsync(errorRecord.Message); if (oldErrorRecord == null) { ErrorRecords.Add(errorRecord); } else { oldErrorRecord.Count++; oldErrorRecord.LastDateTime = errorRecord.LastDateTime; ErrorRecords.Update(oldErrorRecord); } await SaveChangesAsync(); } }