Knight Data Access Layer
Overriding Mappings At RunTime
Basic Tasks C# > Mapping > Overriding Mappings At RunTime

Mappings can be built in several different ways:

 

Each one of the mappings above can be overridden at run time in code.  The is particularly useful if in your application you need to change your database at run time to point to a different schema, for example pointing to a QA schema versus a UAT schema.  See the Schema property on the table object.  Changing table names is useful when needing to point to staging tables or archive tables for use in ETL scenarios. 

 

Example

 

IDataHelper db = DataHelper.SessionFactory();

Table table = _db.Mapper.GetObjectMap(typeof(Customer));

table.TableName = "Customer_Staging";

table.Schema = "TestEnvironment4.";