Click or drag to resize

ValueType properties

Properties in the domain object can be of non-nullable type - [System.ValueType]. Initially, these properties might not have value. The domain system provides ways to access such properties. The methods in this topic require the extensions namespace to be used: Aloe.SystemFrameworks.Domain.Extensions

Backing Data Attributes

Each data property in a domain object has a backing data attribute. The domain system provides a method to access the backing data attribute: GetDataAttributeOrDefault``2(UMP, ExpressionFuncUMP, UMP) The backing data attributes are used internally to get the backing untyped value of the property, in order to cast to nullable value. However, this method can be usefull also for other scenarios.

Working with value type properties

The domain system provides several methods for accessing value type properties. This method allows getting a nullable value from a value type property: GetValueOrDefaultTObject, TResult(TObject, ExpressionFuncTObject, TResult).

This method allows checking whether a value type property has a value: HasValueTObject, TResult(TObject, ExpressionFuncTObject, TResult).

The DataAttribute type has a method, which works the other way around - if you already have the data attribute, you can check whether it has value for a specific domain object. This is done with: HasValue(DomainObject). This is usually usefull for loops cycling through all data attributes.

Example:

Customer c = new Customer(tr);
//For the purposes of this example, lets accept that DefaultDeliveryTermDays
//does not have a default value

//will show 0, which is default(int)
Console.WriteLine(c.DefaultDeliveryTermDays);

//get the backing data attribute
DataAttribute a = c.GetDataAttributeOrDefault(s => s.DefaultDeliveryTermDays);

//get a nullable value
var v = c.GetValueOrDefault(s => s.DefaultDeliveryTermDays);
if(v == null)
  Console.WriteLine("null");

//check whether the property has value
if(c.HasValue(s => s.DefaultDeliveryTermDays))
  Console.WriteLine("Has value!");

//same as above, but use the data attribute
if(a.HasValue(c))
  Console.WriteLine("Has value!");

//same as above, but use AttributeValue
if(c[a].HasValue)
  Console.WriteLine("Has value!");
See Also