IdeaBlade.EntityModel Assembly > IdeaBlade.EntityModel.Extensions Namespace > EntityAspectExtensions Class : IsNullEntity Method |
'Declaration
<ExtensionAttribute()> Public Shared Function IsNullEntity( _ ByVal entity As EntityAspect _ ) As Boolean
'Usage
Dim entity As EntityAspect Dim value As Boolean value = EntityAspectExtensions.IsNullEntity(entity)
[Extension()] public static bool IsNullEntity( EntityAspect entity )
// 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);
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2