Check for a valid entity

Posts   
 
    
imakimak
User
Posts: 62
Joined: 18-Mar-2010
# Posted on: 08-Apr-2010 16:00:13   

Sorry for my ignorrance but you can tell from my question I am a beginner with llbl. I want to check if an entry in database exists, so I worte this code


MyEntity entity = new MyEntity();
entity.FetchUsingPK(someID);
if ( entity == null ) Console.WriteLine("this entry does not exists in db");

However even if I do not have this particular row present in db table, entity is still not null ( probably I have instantiate the object itself and FetchUsingPK does not turn it to null). What is the best way of doing this type of check?

imakimak
User
Posts: 62
Joined: 18-Mar-2010
# Posted on: 08-Apr-2010 16:18:45   

I think I am suppose to check the bool type returned by FetchUsingPK and not the entity object itself.