Detecting that an entity is present in the database

Posts   
 
    
JayBee
User
Posts: 282
Joined: 28-Dec-2006
# Posted on: 03-Dec-2008 14:43:17   

Hi,

I'm using SelfService.

I have a program in which an entity is created by entering its primary key.

XXXEntity xxx = new XXXEntity(pk);

Is there a property or method that can be used to verify that xxx was retrieved from the database instead of initially created by LLBLGen?

Kind regards,

Jan

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 03-Dec-2008 14:50:04   

xxx.Fields.State

Which is an EntityStateWnum with the following possible values:

New Entity is new. It can be empty or filled, but is not saved (yet) to the persistent storage.
**Fetched **Entity is filled with its data from the persistent storage. It can be changed since the fetch.
**OutOfSync **Entity is out of sync with its physical entity in the persistent storage. An Entity is marked OutOfSync when a succesful Save action is performed. An Entity will re-fetch itself when in the state OutOfSync when a property is read or Refetch() is called. The state will then be set to Fetched.
**Deleted **Adapter specific. If an entity has the state Deleted, it is no longer available in the persistent storage.

JayBee
User
Posts: 282
Joined: 28-Dec-2006
# Posted on: 03-Dec-2008 15:01:24   

Thanks,

Works fine.

Jan