-
Notifications
You must be signed in to change notification settings - Fork 42
Override database access
There are some times when you need to override how GenericServices reads and writes to the database. As all the methods to do that are virtual then that is not a problem. Sometimes you just want to tweak something before or after calling the base method, but alternatively you can do the whole job yourself.
Below are some examples of where this might be used.
Have a look at NewOrderDto.cs and its overriding of CreateDataFromDto
In the Providing extra data example we had dropdownlists to help the user. When we create or update that data item we need to use the data coming back from those dropdownlists to fill in some of the data. See the overriding of CreateDataFromDto
and UpdateDataFromDto
in DetailPostDto
class;
Domain-Driven Design (DDD) database
If you are using DDD it is pretty certain you will need to override the CreateDataFromDto
and UpdateDataFromDto
methods on many data classes. This is because a DDD design will not allow write access to some database properties, but instead provide methods or a static factory for create and update.
Create and Update of data via DTOs is complex. I have written a long article about this subject on my technical Blog site, www.thereformedprogrammer.net .
Live example web sites!
Introduction/Overview
Commands and options
- Introduction to Commands
- Key interfaces
- Calculated properties
- DoNotCopyBackToDatabase attribute
- Configuration Options
Data Transfer Objects (DTOs)