Model
Model is the short for the Data Model class or object which represents the application data entry.
It can map the application data entry to a database entry (for example, table, view, stored procedure, or a SQL query) by applying attributes to the class or property.
For example, to query the result set from a database, you can apply
TableAttribute
orFromTableAttribute
to the class which defines the table it maps to, then applySqlWhereAttribute
to the class that defines the search condition for the SQL SELECT statement, and useSqlParameterAttribute
to make the SQL statement parameterized. To save data changes to the database, you can applyKeyAttribute
to one or more properties in the class that defines the primary key in the database, or applyPropertySaveAttribute
to define how to save the property to the database.It can define the relationship between one application data entry and another.
For example, there is a master-detail relationship between the department and courses, then you can apply
EmbededModelAttribute
to a property, which represents the courses, in the department class.After the model class is instantiated, a model object can represent a row of the application data entry, such as a department, a course, a customer etc.