1.2005.1: SelfServicing FetchViaPK change

Posts   
 
    
caseyry
User
Posts: 79
Joined: 25-Feb-2005
# Posted on: 25-Oct-2005 19:04:19   

Regarding this note in the release notes: "PK fetches of single entities now set the PK field(s) even if the entity isn't fetched because it's not found. So the returned entity object always has the PK fields set now, even if the state is 'New'. "

If I understand this correctly, and based on an NUnit test, the code below returns a non-existant object with it's IsNew property set to true. I'm just curious about why this was done?



MyEntity myEntity = new MyEntity();
myEntity.FetchUsingPK(-1); // returns false
int i = myEntity.primaryKey; //i is assigned -1;


Thanks, -Ryan Casey

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 25-Oct-2005 21:16:06   

caseyry wrote:

Regarding this note in the release notes: "PK fetches of single entities now set the PK field(s) even if the entity isn't fetched because it's not found. So the returned entity object always has the PK fields set now, even if the state is 'New'. "

If I understand this correctly, and based on an NUnit test, the code below returns a non-existant object with it's IsNew property set to true. I'm just curious about why this was done?


MyEntity myEntity = new MyEntity();
myEntity.FetchUsingPK(-1); // returns false
int i = myEntity.primaryKey; //i is assigned -1;


myEntity is already instantiated. The PK is set because the internal fetch logic is re-done, it's now more streamlined, more code is re-used.

Frans Bouma | Lead developer LLBLGen Pro