I have a generic methode for load the entity. I need to check result value for null value.
public TEntity LoadById(long id)
{
TEntity result = SessionInstance.Load<TEntity>(id);
if (result != null) //This condition is always true
if (result.Id == 0 ) //Throws ObjectNotFoundException
throw new Exception("Ex Text");
return result;
}
But my condition ( if (result != null)
) is always true and next line result.Propagate()
is throw ObjectNotFoundException
exception by this message : No row with the given identifier exists[RCISP.Domain.Entities.Person#1000]
Because result entity is a proxy. How can I check a condition for null value in a proxy?