Extending Dapper.CX with Opt in Interfaces - adamfoneil/Dapper.CX GitHub Wiki
There are a number of interfaces you can implement on your model classes that enable a lot of functionality typically needed in enterprise applications. These interfaces come from my AO.Models project. This is a separate package so you can add these to your model project without adding a Dapper dependency.
-
IAudit provides a way to record user and timestamps on records. Example: SampleApp.Models.Conventions.BaseTable
-
ICustomGet lets you inject a custom FROM and WHERE clause in your
Get
operations. -
IDbSaveable used internally to support the change tracking feature on LoggedChangeTracker. You can use it as a general-purpose way to make any object able to be stored in a database.
-
IGetRelated lets you perform additional gets or queries related to a row. Example: BlazorServerDemo.Models.WorkItem
-
IPermission provides a way to implement permission checks for get, delete, and save operations.
-
ISqlObjectCreator used internally to enable change tracking feature to create tables it needs during Startup.AddChangeTracking. You can use as a general-purpose way to make any object emit SQL DDL create statements.
-
ITenantIsolated<T> used in conjunction with
ITenantUser<T>
to assure tenant isolation in multi-tenant apps. ImplementITenantIsolated<T>
on your model classes andITenantUser<T>
on your user profile class, and Dapper.CX will compare the the tenant Id values during Get and Save operations, and throw an exception if a user attempts to modify or access a row belonging to a different tenant. Example: SampleApp.Models.UserProfile and SampleApp.Models.Item. -
ITextLookup is used internally by the change tracking feature to convert selected foreign key values into human-readable text values.
-
ITrigger lets you add trigger-like functionality to your model classes.
-
IUserBase provides a way to return the user's name and local time. Several other Dapper.CX features depend on this. Please see the wiki topic on setting up Dapper.CX with dependency injection for more info. Example: SampleApp.Models.UserProfile.
-
IValidate provides a way to perform server-side validation on model classes. Examples: SampleApp.Models.Item and SampleApp.Models.UserProfile
Roadmap
- delete tracking and delete undo