mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
Potential fix for option saving
This commit is contained in:
@@ -37,4 +37,18 @@ public static class DbContextExtension
|
||||
|
||||
entry.State = EntityState.Modified;
|
||||
}
|
||||
|
||||
public static void AddOrUpdate(this DbContext dbContext, object entity)
|
||||
{
|
||||
try
|
||||
{
|
||||
dbContext.Update(entity);
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException e)
|
||||
{
|
||||
dbContext.Add(entity);
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user