Last active
April 8, 2016 19:53
-
-
Save dcomartin/f8fa34974a72f20434fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<int> SaveChangesAsync(Guid messageId) | |
{ | |
using (var transaction = Database.BeginTransaction()) | |
{ | |
var result = await SaveChangesAsync(); | |
IdempotentIds.Add(new Idempotent { IdempotentId = messageId }); | |
try | |
{ | |
await SaveChangesAsync(); | |
} | |
catch (DbUpdateException ex) | |
{ | |
// Duplicate Key Error Number | |
if (ex.InnerException?.InnerException != null && (ex.InnerException.InnerException as MySqlException)?.Number == 1062) return 0; | |
throw; | |
} | |
transaction.Commit(); | |
return result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment