Domain object models

Abstracts

A domain object model is an object that represent application data as a user, an employee, a product, etc.

Within this framework a domain object model (or simple a model) is a class that implement Inetdev.Data.IDataModel or that inherits from Inetdev.Data.DataModel (recommended), for example:

                    
        public class Audit : DataModel
        {
            //...   
        }
                    
                
A complete sample of a data model class can be found here.

Defining data properties

A data property is a property that represents application data that will be ultimately stored in a database.

A data property is defined as a normal C# property and it is decorated with an attribute that inherits from Inetdev.Data.IDataProperty, for example:

                    
        public class Audit : DataModel
        {
            string _id;

            [TextDataProperty("Id", DbType.Text, MinLength = 0, MaxLength = 50, FieldName = "_id", PrimaryKey = 1, AutomaticType = AutomaticType.Identity, Caption = "AuditIdCaption", ResourceType = typeof(ModelLabels))]
            public string Id
            {
                get { return _id; }
                set
                {
                    _id = value;
                    NotifyPropertyChanged(_id);
                }
            }
        }
                    
                

Creating, modifying and deleting

Data models are created, modified and deleted through the used of the methods Save() or SaveAsync() for creation and modification and Erase() or EraseAsync() for deletion.

Execution of this methods will execute the appropiated commands againts the database.

Top