View on GitHub

MicroDBHelper-ExpansionPack

Optional Expansion Packs for [MicroDBHelper]

icon

ExpansionPack :: EntityConversion

This expansion pack is focus on convert datas between datatable object and entity model list.

The root section of documents of all optional expansion packs, please visit here.

Generated for Framework Version:

Dependencies

None.

Usage

Define your model class

Firstly, define the data model class. Set the target propertys to Public, that is ready to automatically map with the data column. For example,

class Model
{
    public int ID { get; set; }
    public string Name { get; set; }
}

Call conversion method

There are two alternatives:

Mapping control

Control the behaviors of the mapping process.

Matched name control

By default, library will Compare colnum name of DataTable Object to property name of Model Instance. If both match, then will set the value.

However, in some scenes, maybe you hope to use another name to be matched, then you can use the MicroDBHelpers.ExpansionPack.ColumnAttribute associated to the target property, for example:

class Model
{
    [Column("Identity")]
    public int ID { get; set; }
}

Case sensitive control

By default, it is case sensitive. If you hope the library ignore case when compare names, there are two alternatives:

Please note again, if you set the EntityConversionDefaultSettings.CaseSensitiveToColumnName and use ColumnAttribute both, then the finall rule of Case sensitive to that one property would in ColumnAttribute prevail.

Ignore specified column

Sometimes,you may hope to ignore some columns, either convert to entity list, or convert to datatable.

To do this, just need to use the MicroDBHelpers.ExpansionPack.IgnoreAttribute associated to the expected propertys.

Download compiled binary file

If you needn’t to got the code and bulid by yourself for the moment, I also offer the newest compiled file in the BUILD directiory for your convenience.

Build Directory

NuGet

Install-Package MicroDBHelper-ExpansionPack-EntityConversion link




o(∩_∩)o The root section of documents of all optional expansion pack, please visit here.