IdeaBlade DevForce 2010 Help Reference
IsNullEntity Property
See Also  Example Send Feedback
IdeaBlade.EntityModel Assembly > IdeaBlade.EntityModel Namespace > EntityAspect Class : IsNullEntity Property



Returns whether the current instance is a null entity.

Syntax

Visual Basic (Declaration) 
Public ReadOnly Property IsNullEntity As Boolean
Visual Basic (Usage)Copy Code
Dim instance As EntityAspect
Dim value As Boolean
 
value = instance.IsNullEntity
C# 
public bool IsNullEntity {get;}
C++/CLI 
public:
property bool IsNullEntity {
   bool get();
}

Example

C#Copy Code
// Sample showing IsNullEntity check.

    DomainModelEntityManager mgr = new DomainModelEntityManager();

    // Try to retrieve order #1 - FirstOrNullEntity will return null entity if not found.
    OrderSummary order = mgr.OrderSummaries.FirstOrNullEntity(o => o.Id == 1);
    if (order.IsNullEntity)
       Console.WriteLine("Order #1 not found");

    // Now try another order, using FirstOrDefault, which returns null if not found.
    OrderSummary order2 = mgr.OrderSummaries.FirstOrDefault(o => o.Id == 2);
    if (order2 == null) {
       Console.WriteLine("Order #2 is null");
    } else if (order2.IsNullEntity) {
       Console.WriteLine("Order #2 is a null entity");
    }

    // Note, you can't use .First (since the EF will throw an exception).
    OrderSummary order3 = mgr.OrderSummaries.First(o => o.Id == 3);

Remarks

The EntityManager will return a NullEntity instead of a null value when a requested entity is not found.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2013 All Rights Reserved.