Type-Less Property

In NObject O/R Mapping persistence layer, using type-less property can be very convenient to transform types. The following is a sample of type-less property:

Product p = new Product(om);

decimal dPrice;

string sPrice;

 

p._UnitPrice.AsInt16 = 100;

p._UnitPrice.AsDouble = 100.0;

p._UnitPrice.AsDecimal = 100.0M;

p._UnitPrice.AsString = "100.0";

p._UnitPrice.Value = 100;

p._UnitPrice.Value = "100";

 

dPrice = p._UnitPrice.AsDecimal;

sPrice = p._UnitPrice.AsString;

Using type-less property also can be very convenient to judge if a property is null:

// Judge if the property is null

if (order._OrderDate.IsNull)

{

  // ...

}

 

// Judge if the property is null or empty string

if (order._ShipAddress.IsNullOrEmpty)

{

  // ...

}

 

Related Topics

Using NObject Object Property