-
Notifications
You must be signed in to change notification settings - Fork 42
Support commands
There are a couple of support methods in GenericServices that you may found useful too. They are:
GenericServices uses the method SaveChangesWithChecking()
/ SaveChangesWithCheckingAsync()
to
commit any changes to the database. It returns an ISuccessOrErrors status saying whether
the save was successful.
This method catches Validation Errors and some SQL Errors (see Dictionary for catching SQL errors) and returns Errors in the status rather than throwing an exception. You may find this useful elsewhere in your application.
The signature of the methods are:
ISuccessOrErrors SaveChangesWithChecking()
Task<ISuccessOrErrors> SaveChangesWithCheckingAsync()
This is used when you expect to get one result for a query. It returns a status and, if the status .IsValid()
property is true, the single class found by the query. It also optionally called the configuration set property RealiseSingleWithChecking(exception, callingMethodName)
if there is an exception. This allows the developed to check the exception and return an error if appropriate.
Use this when it is preferable to get error messages rather than an exception.
The method is an extension method, so it can chained onto the end of a LINQ query. The signature of the methods are:
ISuccessOrErrors<T> RealiseSingleWithErrorChecking<T>(this IQueryable<T> request)
Task<ISuccessOrErrors<T>> RealiseSingleWithErrorCheckingAsync<T>(this IQueryable<T> request)
Live example web sites!
Introduction/Overview
Commands and options
- Introduction to Commands
- Key interfaces
- Calculated properties
- DoNotCopyBackToDatabase attribute
- Configuration Options
Data Transfer Objects (DTOs)