Skip to content

DmTableFactory ​

Namespace: MJCZone.DapperMatic.Models

Assembly: MJCZone.DapperMatic

Summary ​

Factory for creating DmTable instances for types.

static public

Contents ​

Methods (13)

Methods ​

MethodSummary
ConfigureConfigure ahead of time any custom configuration for mapping types to DmTable instances. Call this b...
ConfigureConfigure a specific type to your liking. This method can be used to customize the behavior of DmTab...
ConfigureConfigure a specific type to your liking. This method can be used to customize the behavior of DmTab...
GetTableReturns an instance of a DmTable for the given type. If the type is not a valid DmTable, denoted by ...
GetTableNameThere are times we just need the schema name and table name for a type, without the full DmTable ins...
GetPropertyInfo
GetColumnNameGets the column name for a property, considering various attributes that may specify the column name...
GetColumnName
GetColumnNameGets the column name for a property, considering various attributes that may specify the column name...
GetType
ToString
Equals
GetHashCode

Configure ​

Configure ahead of time any custom configuration for mapping types to DmTable instances. Call this before the application attempts to map types to DmTable instances, as the mappings are cached once generated the very first time.

csharp
void Configure(Type configure)

Parameters ​

  • configure (Type) - A delegate that receives the Type that is currently being mapped to a DmTable, and an initial DmTable that represents the default mapping before any customizations are applied. The delegate will run when the GetTable method is run for the first time each particular type.

Configure ​

Configure a specific type to your liking. This method can be used to customize the behavior of DmTable generation.

csharp
void Configure(DmTable} configure)

Parameters ​

  • configure (DmTable}) - A delegate that receives an initial DmTable that represents the default mapping before any customizations are applied. The type mapping is created immediately and the delegate is run immediately as well.

Configure ​

Configure a specific type to your liking. This method can be used to customize the behavior of DmTable generation.

csharp
void Configure(Type type, DmTable} configure)

Parameters ​

  • type (Type) - Type that should be mapped to a DmTable instance.
  • configure (DmTable}) - A delegate that receives an initial DmTable that represents the default mapping before any customizations are applied. The type mapping is created immediately and the delegate is run immediately as well.

GetTable ​

Returns an instance of a DmTable for the given type. If the type is not a valid DmTable, denoted by the use of a DmTableAAttribute on the class, this method returns null.

csharp
DmTable GetTable(Type type)

Parameters ​

  • type (Type) - The type to map to a DmTable instance.

Returns ​

Type: DmTable

A DmTable instance representing the type.

GetTableName ​

There are times we just need the schema name and table name for a type, without the full DmTable instance. We also may need this information without causing a recursive call to GetTable, which may have foreign keys that reference a table with a foreign key back to it, leading to a stack overflow.

csharp
(string?, string) GetTableName(Type type, bool ignoreCache)

Parameters ​

  • type (Type) - The type to extract a schema and table name for.
  • ignoreCache (bool) - If true, the cache will be ignored and the schema and table name will be extracted from the type's attributes. If false, the cache will be checked first, and if the type is found in the cache, the cached values will be returned.

Returns ​

Type: (string?, string)

A tuple containing the schema name and table name for the type.

GetPropertyInfo ​

csharp
GetPropertyInfo()

GetColumnName ​

Gets the column name for a property, considering various attributes that may specify the column name.

csharp
string GetColumnName(PropertyInfo property)

Parameters ​

  • property (PropertyInfo) - The property to get the column name for.

Returns ​

Type: string

The column name for the property.

GetColumnName ​

csharp
GetColumnName()

GetColumnName ​

Gets the column name for a property, considering various attributes that may specify the column name.

csharp
GetColumnName(PropertyInfo property, DmColumnAttribute columnAttribute)

Parameters ​

  • property (PropertyInfo) - The property to get the column name for.
  • columnAttribute (DmColumnAttribute) - The DmColumnAttribute applied to the property, if any.

Returns ​

The column name for the property.

GetType ​

csharp
GetType()

ToString ​

csharp
ToString()

Equals ​

csharp
Equals()

GetHashCode ​

csharp
GetHashCode()