Knight Data Access Layer
Mapping By Code VB.NET
Basic Tasks VB.NET > Mapping > Mapping By Code VB.NET

Mappings can be entirely created in code.  Mappings can be created from scratch or mappings can be augmented by generating the mapping first.

 

Manual Mapping

Dim db As IDataHelper = DataHelper.SessionFactory()

Dim table As New Table(GetType(Person))

table.TableName = "People"

Dim field As New Field(table, "FirstName", "FirstName")

table.Fields.Add(field)

db.Mapper.ObjectMap.Add(GetType(Person),table)

 

Partially Automatic Mapping

Dim db As IDataHelper = DataHelper.SessionFactory()

Dim table As Table = _db.Mapper.GetObjectMap(GetType(Customer))

table.Fields.First(Function(o) o.PropertyInfoString = "Name").DatabaseType = DbType.String