/// <summary> /// Save Async /// </summary> public async Task <int> SaveAsync() { try { return(await Task <int> .Run(() => context.SaveChangesAsync())); } catch (Exception e) { if (e.InnerException != null) { e = e.InnerException; } List <string> lines = new List <string>(); foreach (var error in e.Data) { lines.Add(error.ToString()); } string errorsFilePath = "errors.txt"; if (!File.Exists(errorsFilePath)) { File.Create(errorsFilePath); FileIOPermission fp = new FileIOPermission(FileIOPermissionAccess.AllAccess, errorsFilePath); } File.AppendAllLines("errors.txt", lines); throw e; } }
/// <summary> /// Save Async /// </summary> public async Task <int> SaveAsync() { try { return(await Task <int> .Run(() => context.SaveChangesAsync())); } catch (Exception e) { List <string> lines = new List <string>(); foreach (var error in e.Data) { lines.Add(error.ToString()); } System.IO.File.AppendAllLines(@"E:\errors.txt", lines); throw e; } }