Skip to content

MJCZone.DapperMatic.DataAnnotations ​

Assembly: MJCZone.DapperMatic

Classes ​

NameDescription
DmCheckConstraintAttributeAttribute to define a check constraint.
DmColumnAttributeAttribute to define a database column.
DmConcurrencyTokenAttributeMarks the property that changes on every write, so that a row written by key is written only if no one else has written it since it was read: an <c>int</c> or <c>long</c> (incremented), a <c>Guid</c> (new on each write), or a <c>byte[]</c> (new random bytes, or on SQL Server a <c>rowversion</c> column the database writes). A row that changed throws <c>DmConcurrencyException</c>.
DmCreatedAtAttributeMarks the property the DML methods set to the time a row is inserted, from <c>DmDefaults.Clock</c>, in UTC: a <c>DateTime</c> or a <c>DateTimeOffset</c>. Updates never change it.
DmCreatedByAttributeMarks the property the DML methods set to the user who inserts a row, from the scope's <c>WithUser</c> or <c>DmDefaults.User</c>, converted to the property's type. Updates never change it, and it is left as it is when there is no user.
DmDefaultConstraintAttributeAttribute to define a default constraint on a property.
DmForeignKeyConstraintAttributeAttribute to define foreign key constraints on a class or property.
DmIgnoreAttributeAttribute to ignore a property in the mapping.
DmIndexAttributeAttribute to define a database index.
DmPrimaryKeyConstraintAttributeAttribute to define a primary key constraint on a table.
DmRelationAttributeMarks a property as a relation to another model's rows, never a column: one related row (<c>public Customer? Customer</c>) or many (<c>public List<OrderLine>? Lines</c>). Relations are filled only when a query asks (<c>Include</c>), and can be filtered on (<c>o => o.Lines!.Any(l => ...)</c>).
DmSoftDeleteAttributeMarks the property that says a row is deleted: a <c>bool</c> (true when deleted) or a nullable <c>DateTime</c> or <c>DateTimeOffset</c> (when it was deleted). The DML methods' deletes then set it instead of removing the row, and every read leaves deleted rows out unless the query says <c>IncludeDeleted()</c> or <c>OnlyDeleted()</c>; <c>HardDeleteAsync</c> removes rows.
DmTableAttributeAttribute to define the table name and schema for a class.
DmTenantKeyAttributeMarks the property that says which tenant a row belongs to. Every DML method then reads and writes only the scope's tenant's rows (<c>ForTenant(id)</c>, or <c>DmDefaults.TenantId</c>), and sets it on inserted rows; with no tenant, the methods refuse the model, unless the scope says <c>AllTenants()</c>.
DmUniqueConstraintAttributeAttribute to define a unique constraint on a table.
DmUpdatedAtAttributeMarks the property the DML methods set to the time a row is inserted or updated, from <c>DmDefaults.Clock</c>, in UTC: a <c>DateTime</c> or a <c>DateTimeOffset</c>.
DmUpdatedByAttributeMarks the property the DML methods set to the user who inserts or updates a row, from the scope's <c>WithUser</c> or <c>DmDefaults.User</c>, converted to the property's type; left as it is when there is no user.
DmViewAttributeAttribute to define a database view.