Skip to content
Squil11ams edited this page Nov 9, 2022 · 7 revisions

How to use

Setting up Model

You have two options to setup your object model.

1st Extend the MerlinModelBase class to enable auto population of fields.

class MyData : MerlinModelBase { public int record_id { get; set; } public string record_name { get; set; } public MyCustomEnum record_enum { get; set; } }

If the fields have the same name as the corresponding database column then thats all you need.

See the MerlinModelBase page for more options including the available attributes.

2nd option would be to implement the IMerlinModel interface

`class MyData : IMerlinObject { public int record_id { get; set; } public string record_name { get; set; } public MyCustomEnum record_enum { get; set; }

public void SetDataObject(IDataReader data, int Flag, string Prefix="")
{
    this.record_id = (int)data["field_1"];
    this.record_name = (string)data["field_2"];
    this.record_enum = (string)data["field_3"];
}

}`

Clone this wiki locally