C# Class GenericServices.SaveChangesExtensions

This contains extention errors that change SaveChanges/SvaeChangesAsync into returning error messages rather than an exception on certain types of errors.
Show file Open project: JonPSmith/GenericServices

Public Methods

Method Description
SaveChangesWithChecking ( this db ) : ISuccessOrErrors

This extension will undertake a SaveChanges but will catch any validation errors or specific SqlException specified in ServicesConfiguration.SqlErrorDict and return them as errors rather than throw an exception

SaveChangesWithCheckingAsync ( this db ) : Task

This extension will undertake a SaveChangesAsync but will catch any validation errors or specific SqlException specified in ServicesConfiguration.SqlErrorDict and return them as errors

Private Methods

Method Description
TryDecodeDbUpdateException ( System.Data.Entity.Infrastructure.DbUpdateException ex ) : IEnumerable

This decodes the DbUpdateException. If there are any errors it can handle then it returns a list of errors. Otherwise it returns null which means rethrow the error as it has not been handled

Method Details

SaveChangesWithChecking() public static method

This extension will undertake a SaveChanges but will catch any validation errors or specific SqlException specified in ServicesConfiguration.SqlErrorDict and return them as errors rather than throw an exception
public static SaveChangesWithChecking ( this db ) : ISuccessOrErrors
db this
return ISuccessOrErrors

SaveChangesWithCheckingAsync() public static method

This extension will undertake a SaveChangesAsync but will catch any validation errors or specific SqlException specified in ServicesConfiguration.SqlErrorDict and return them as errors
public static SaveChangesWithCheckingAsync ( this db ) : Task
db this
return Task