Table of Contents


Defining Entities and Models

The Magentrix Online Database provides the ability to generate persistable data models that are stored and indexed into the Magentrix Cloud Database. Custom Data Models can also be created using Magentrix Active Classes to perform special or customized application logics. A Data Model is a class with properties that can be used as holding container for data. Moreover, you can use the Data Model to specify Metadata, used to describe the properties of the Models that was not easily achievable by other means. Magentrix implements most Data Annotations supported by Microsoft, and the following Annotations can be used to further customize the Data Model's Metadata in order to control the presentation and data validation aspects of your Models.

 

DateTime

This attribute annotates the model property to allow you to specify whether the property is Date, DateTime or just Time.

[DateTime(DateKind = DateTimeFormat.Date)]
public DateTime? EndDate { get; set; }

[DateTime(DateKind = DateTimeFormat.DateTime)]
public DateTime? StartDate { get; set; }

​[DateTime(DateKind = DateTimeFormat.Time)]
public string StartTime { get; set; }

 

Currency Field

This attribute is used to decorate a decimal property as a currency field.

//[Currency(length,decimalplaces)]

[Currency(8,2)]
public decimal? Amount { get; set; }

 

Number Field

This property is used to decorate a decimal property as a Number field.

//[Number(length, decimalplaces)

[Number(4,6)]
public decimal? Weight { get; set; }

 

Percent Field

This property is used to turn a decimal property into a Percent field.

//[Percent(length,decimalplaces)]

// Can hold values such as %20, %35.50, %99.99
[Percent(2,2)]
public decimal? Progress { get; set; }

 

Email Field

This property is used to decorate a string property as Email field.

[Email]
​public string Email { get; set; }

 

Phone Field

This property is used to decorate a string property as Phone or Fax field.

[PhoneNumber]
​publicstring Phone { get; set; }

 

URL Field

This property is used to decorate a string property as a URL field.

[UrlAddress]
public string Website { get; set; }

 

Long Text Field

This property is used to decorate a string property as Long Text field.

[DataType(DataType.MultilineText)]
public string Description { get; set; }

 

HTML Rich-Text Field

This property is used to decorate a string property as HTML rich-text field.

[DataType(DataType.Html)]
public string Comments { get; set; }