Click or drag to resize

DomainObjectIsGhost Property

Returns true when the object is a ghost object

Namespace:  Aloe.SystemFrameworks.Domain
Assembly:  Aloe.SystemFrameworks.Domain (in Aloe.SystemFrameworks.Domain.dll) Version: 20.1.3.5
Syntax
public abstract bool IsGhost { get; }

Property Value

Type: Boolean
Remarks
Ghost objects allow easy traversing of relationship chains without null checking. Ghost object are primarily used by following a reference to EntityObject, but is possible other descendants of DomainObject to also allow and use ghost objects concept. The basic idea and usage of ghost objects are illustrated in the following example:
SalesOrderLine l = ...;
l.Product = null;
//without ghost objects we would have to first check
if(l.Product == null)
  Console.WriteLine("null");
else
  Console.WriteLine(l.Product.Name);

//with ghost, we can work straightforward
//this would print null
Console.WriteLine(l.Product.Name);
Ghost objects are special instances, usually created by following a null reference. Ghosts are of the same type as the other objects of the same repository. All data attributes of ghost objects return null when get and throw InvalidOperationException if an attempt is made to set a value. The references of ghost objects return other ghost objects when get and throw InvalidOpeartionException on set.
See Also