Class ModelBuilder
ModelBuilder, which know materialize data from Db to objects.
Inheritance
System.Object
ModelBuilder
Implements
Namespace: Kros.KORM.Materializer
Assembly: Kros.KORM.dll
Syntax
public class ModelBuilder : IModelBuilder
Constructors
ModelBuilder(IModelFactory)
Initializes a new instance of the ModelBuilder class.
Declaration
public ModelBuilder(IModelFactory modelFactory)
Parameters
Type | Name | Description |
---|---|---|
IModelFactory | modelFactory | The model factory. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Argument 'modelFactory' is required. |
Methods
Materialize<T>(DataRow)
Materialize data from dataRow
to instances of model type T
.
Declaration
public T Materialize<T>(DataRow dataRow)
Parameters
Type | Name | Description |
---|---|---|
System.Data.DataRow | dataRow | Data row of the table. |
Returns
Type | Description |
---|---|
T | Model. |
Type Parameters
Name | Description |
---|---|
T | Type of model. |
Materialize<T>(DataTable)
Materialize data from data table to instances of model type T.
Declaration
public IEnumerable<T> Materialize<T>(DataTable table)
Parameters
Type | Name | Description |
---|---|---|
System.Data.DataTable | table |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T> | IEnumerable of models. |
Type Parameters
Name | Description |
---|---|
T | Type of model. |
Materialize<T>(IDataReader)
Materialize data from reader to instances of model type T.
Declaration
public IEnumerable<T> Materialize<T>(IDataReader reader)
Parameters
Type | Name | Description |
---|---|---|
System.Data.IDataReader | reader | The reader from which materialize data. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T> | IEnumerable of models. |
Type Parameters
Name | Description |
---|---|
T | Type of model. |
Remarks
If disposeReader is true and connection is not null, then connection will be disposed.
Examples
var people = database.ModelBuilder.Materialize<Person>(dataTable);