The Entity structure has synchronous and asynchronous versions of the same IO-related methods as SaveChanges and SaveChangesAsync . How can I create new methods that perform the same task minimally without "duplicating" the code?
public bool SaveChanges() { //Common code calling synchronous methods context.Find(...); //Synchronous Save return context.SaveChanges(); } public async Task<bool> SaveChangesAsync() { //Common code asynchronous methods await context.FindAsync(...); //Asynchronous Save return await context.SaveChangesAsync(); }
source share