Data Types
Data types control how property values are stored, validated, and displayed. Every [Property<T>] attribute references a data type as its generic parameter.
Type Hierarchy
DataTypeBase (abstract)
├── StringDataTypeBase
│ └── Text (max 100)
│ ├── IdText (max 15, uppercase, barcode-safe)
│ ├── MultilineText (unlimited)
│ ├── ProperNoun (max 50, auto title-case)
│ ├── Title (max 80)
│ ├── Email (max 50, validates format)
│ ├── Phone (max 25, auto-formats USA numbers)
│ ├── Url (max 500, validates URL)
│ └── Website (max 200, validates URL)
├── DecimalDataTypeBase
│ └── Decimal (2 stored / 2 visual decimals)
│ ├── Currency (2 decimals)
│ └── PositiveDecimal (2 decimals, rejects negative)
├── Boolean
│ └── DefaultTrueBoolean (defaults to true)
├── Integer
├── DateTime
├── DateOnly
└── Enum
Core String Types
| Type |
CLR Type |
Max Length |
Auto-Correct |
Validation |
Text |
string |
100 |
Trims whitespace |
— |
IdText |
string |
15 |
Uppercases, removes non-barcode characters (Code 39) |
— |
MultilineText |
string |
Unlimited |
Trims whitespace |
— |
ProperNoun |
string |
50 |
Converts to Title Case |
— |
Title |
string |
80 |
Trims whitespace |
— |
Email |
string |
50 |
Trims whitespace |
Validates email format |
Phone |
string |
25 |
Formats USA 10-digit numbers to (XXX) XXX-XXXX, supports extensions |
— |
Url |
string |
500 |
Trims whitespace |
Validates URL format |
Website |
string |
200 |
Trims whitespace |
Validates URL format |
Usage
[Property<DataTypes.IdText>("SKU")]
public partial string Sku { get; set; }
[Property<DataTypes.ProperNoun>("Full name")]
public partial string FullName { get; set; }
[Property<DataTypes.Email>("Email")]
public partial string Email { get; set; }
[Property<DataTypes.MultilineText>("Notes")]
public partial string Notes { get; set; }
Core Numeric Types
| Type |
CLR Type |
Stored Decimals |
Visual Decimals |
Validation |
Decimal |
decimal |
2 |
2 |
— |
Currency |
decimal |
2 |
2 |
— |
PositiveDecimal |
decimal |
2 |
2 |
Rejects values < 0 |
Integer |
int |
— |
— |
— |
Decimal types automatically round values to their stored precision.
Usage
[Property<DataTypes.Decimal>("Unit weight")]
public partial decimal UnitWeight { get; set; }
[Property<DataTypes.Currency>("Shipping")]
public partial decimal ShippingAmount { get; set; }
[Property<DataTypes.PositiveDecimal>("Factor")]
public partial decimal Factor { get; set; }
[Property<DataTypes.Integer>("Current Count")]
public partial int CurrentCount { get; set; }
Core Boolean Types
| Type |
CLR Type |
Default Value |
Boolean |
bool |
false |
DefaultTrueBoolean |
bool |
true |
Usage
[Property<DataTypes.Boolean>("Require integer quantities")]
public partial bool RequireIntegerQuantities { get; set; }
Core Date Types
| Type |
CLR Type |
Description |
DateOnly |
DateOnly? |
Date without time component |
DateTime |
DateTime? |
Date and time |
Usage
[Property<DataTypes.DateOnly>("Order date")]
public partial DateOnly? OrderDate { get; set; }
[Property<DataTypes.DateTime>("Closed date")]
public partial DateTime? ClosedDate { get; set; }
Enum Type
| Type |
CLR Type |
Description |
Enum |
Any C# enum |
Stores enum values by their underlying integer |
Usage
public enum SalesOrderStatus
{
Draft = 0,
Open = 1,
Fulfilled = 3,
Closed = 5
}
[Property<DataTypes.Enum>("Status")]
[DefaultValue(SalesOrderStatus.Open)]
public partial SalesOrderStatus Status { get; set; }
ERP-Specific Data Types
These are custom data types defined in the ERP Model project for domain-specific needs. They demonstrate how to extend the type system (see Creating Data Types).
| Type |
CLR Type |
Stored Decimals |
Visual Decimals |
Defined In |
ProductQuantity |
decimal |
10 |
2 |
Benevia.ERP.Model |
ProductUnitPrice |
decimal |
10 |
2 |
Benevia.ERP.Model |
ProductUnitCost |
decimal |
10 |
2 |
Benevia.ERP.Model |
| Type |
CLR Type |
Max Length |
Defined In |
PriceFormula |
string |
75 |
Benevia.ERP.Model |
UomName |
string |
10 |
Benevia.ERP.Model |
Usage
[Property<ProductUnitPrice>("Cost")]
public partial decimal Cost { get; set; }
[Property<ProductQuantity>("Quantity (Each)")]
public partial decimal Quantity { get; set; }
Auto-Correct vs Validation
Data types can provide two kinds of behavior:
- Auto-correct runs immediately when a property is set. It transforms the value silently (e.g.,
IdText uppercases, ProperNoun title-cases, Phone reformats digits).
- Validation runs before save. It rejects invalid values with an error message (e.g.,
Email checks format, PositiveDecimal rejects negatives).
Both are implemented through the Events system in [Logic] classes associated with the data type.