Hi Folks,
I'm having a question on the pre-fetch kinda issue. I'm not sure if this is a bug (I don't think it is).
Alright... I'll get to the point. I have a piece of code here:
ContainerEntity cEntity = new ContainerEntity(200);
Per my understanding, this loads the Container from the table whose primary key is 200. Now if the primary key does not exist in the table, object cEntity gets initialized with default values. Shouldn't the cEntity object be null?
I ask this question because I get an error message (something like 'ContainerID cannot be null') when I do this:
//If PK exists, perform udpate
//else add new row.
//ContainerID 200 does not exist.
ContainerEntity cEntity = new ContainerEntity(200);
if(cEntity!=null)
{
cEntity.Description = "Description";
cEntity.Save();
}
else
{
cEntity = new ContainerEntity();
cEntity.ContainerID = 200;
cEntity.Description = "Description";
cEntity.Save();
}
What's a better way to do this?
Thanks in advance for helping me out.
Arun