Data Model is a collection of classes wherein you will be working with data and business logic. Hence, basically models are business domain-specific containers. It is used to interact with database. It can also be used to manipulate the data to implement the business logic.
To create a micron model, Just extend IMicron Interface. This helps micron model generator to find create then models.
To link a model to a table, Use [Table("TableName")] class attribute,
Micron models must have Primary key property. To define the primary key just add property attribute [Primary].
Primary Key
In the relational model of databases, a primary key is a specific choice of a minimal set of attributes that uniquely specify a tuple in a relation. Informally, a primary key is "which attributes identify a record".
A relationship, in the context of databases, is a situation that exists between two relational database tables when one table has a foreign key that references the primary key of the other table.
To define relationships in micron, use the [Foreign(typeof(Product))] property attribute. It is added to the Foreign key property.
A foreign key is a column or group of columns in a relational database table that provides a link between data in two tables. It acts as a cross-reference between tables because it references the primary key of another table, thereby establishing a link between them.
Example:
Order:
usingMicron;usingSystem;usingSystem.Collections.Generic;namespaceData.Models{ /***ORDER MODEL***/ [Table("orders")]publicpartialclassOrder:IMicron { [Primary]publicInt32 OrderID {get; set;} [Foreign(typeof(Customer))] publicInt32 CustomerID {get; set;} //Foreign key to Customer object model [Foreign(typeof(Employee))]publicInt32 EmployeeID {get; set;} publicString OrderDate {get; set;} //Foreign key to employee object model [Foreign(typeof(Shipper))] publicInt32 ShipperID {get; set;} //Foreign key to shipper object model }}