Link Search Menu Expand Document

EntityMapFluentDefinition


A class that is being used to define a data entity level mappings specifically for the table/columns, primary/identity columns, database types and class/property handlers. It is the result of the Entity() method of the FluentMapper mapper class.

Mapping a Database Table/View

To map a data entity into a specific database table, use the Table() method.

var definition = FluentMapper.Entity<Customer>();
definition.Table("[sales].[Customer]");

It is using the ClassMapper class underneath.

Mapping a Table Column

To map a data entity property into a specific table column, use the Column() method.

var definition = FluentMapper.Entity<Customer>();
definition.Column(e => e.FirstName, "[FName]");

Or via property name.

var definition = FluentMapper.Entity<Customer>();
definition.Column("FirstName", "[FName]");

Or via Field object.

var definition = FluentMapper.Entity<Customer>();
var field = new Field("FirstName");
definition.Column(field, "[FName]");

It is using the PropertyMapper class underneath.

Defining a Primary Property

To define the data entity primary property, use the Primary() method.

var definition = FluentMapper.Entity<Customer>();
definition.Primary(e => e.Id);

Or via property name.

var definition = FluentMapper.Entity<Customer>();
definition.Primary("Id");

Or via Field object.

var definition = FluentMapper.Entity<Customer>();
var field = new Field("Id");
definition.Primary(field);

It is using the PrimaryMapper class underneath.

Defining an Identity Property

To define the data entity identity property, use the Identity() method.

var definition = FluentMapper.Entity<Customer>();
definition.Identity(e => e.Id);

Or via property name.

var definition = FluentMapper.Entity<Customer>();
definition.Identity("Id");

Or via Field object.

var definition = FluentMapper.Entity<Customer>();
var field = new Field("Id");
definition.Identity(field);

It is using the IdentityMapper class underneath.

Mapping a Database Type

To map an equivalent database type into a data entity property, use the DbType() method.

var definition = FluentMapper.Entity<Customer>();
definition.DbType(e => e.DateOfBirth, DbType.DateTime2);

Or via property name.

var definition = FluentMapper.Entity<Customer>();
definition.DbType("DateOfBirth", DbType.DateTime2);

Or via Field object.

var definition = FluentMapper.Entity<Customer>();
var field = new Field("DateOfBirth");
definition.Identity(field, DbType.DateTime2);

It is using the TypeMapper class underneath.

Defining a Class Handler

To define the class handler for the data entity, use the ClassHandler method.

var definition = FluentMapper.Entity<Customer>();
definition.ClassHandler<CustomerClassHandler>();

It is using the ClassHandlerMapper class underneath.

Defining a Property Handler

To define the property handler for the data entity property, use the PropertyHandler() method.

var definition = FluentMapper.Entity<Customer>();
definition.PropertyHandler<CustomerAddressPropertyHandler>(e => e.Address);

Or via property name.

var definition = FluentMapper.Entity<Customer>();
definition.PropertyHandler<CustomerAddressPropertyHandler>("Address");

Or via Field object.

var definition = FluentMapper.Entity<Customer>();
var field = new Field("Address");
definition.PropertyHandler<CustomerAddressPropertyHandler>("Address");

It is using the PropertyHandlerMapper class underneath.