Entity Save not returning new Primary key

Posts   
 
    
rparkins
User
Posts: 66
Joined: 04-May-2005
# Posted on: 07-Mar-2006 17:32:38   

Hi,

I have an Entity that I am running the Save() method on. I have used this method of saving entities since I started using the pro tool with no problems however, I have come up against an issue that someone may be able to help with.

The only difference I can see with this entity compared to my other entities is that the entity contains a binary field, but dont believe this to be the problem.

When I call the Save() method the entity is in fact saved to the database and the new System.Guid is generated accordingly in the database, so in other works the Save works simple_smile

When I examine the object after this save the Primary key (The System.Guid) has not been updated, I am sure this happens in all my other classes.

The System Guid is defined as a primary key and has default value (newid()) and is a row uid. I have placed the code below, and have checked that the Save() method returns true and also called a refetch() after the Save() but still no Guid.

Hope someone can help or point me in the right direction.

Cheers

Rich

OnlinePurchasePendingEntity pending = new OnlinePurchasePendingEntity(); pending.PendingCreated = DateTime.Now; pending.PendingProvider = provider; pending.UserUid = user.UserUID;

MemoryStream ms = new MemoryStream(); // create a new BinaryFormatter instance BinaryFormatter b = new BinaryFormatter(); // serialize the class into the MemoryStream b.Serialize(ms, purchase); ms.Seek(0,0); pending.PendingPurchaseObj = ms.ToArray();

pending.Save();

return pending;

JimHugh
User
Posts: 191
Joined: 16-Nov-2005
# Posted on: 07-Mar-2006 18:03:33   

I don't believe that LLBLGen supports returning guids as database generated keys. As far as I know, there is not an equivalent to select scope_identity() with SQL 2000 and below. SQL 2005 has a newsequentialid() function that is not supported by LLBLGen 1.x

I suspect that you used integer identity primary keys in your other tables.

You can set a new PK on the client side using Guid.NewGuid().

rparkins
User
Posts: 66
Joined: 04-May-2005
# Posted on: 07-Mar-2006 18:12:06   

JimHugh wrote:

I don't believe that LLBLGen supports returning guids as database generated keys. As far as I know, there is not an equivalent to select scope_identity() with SQL 2000 and below. SQL 2005 has a newsequentialid() function that is not supported by LLBLGen 1.x

I suspect that you used integer identity primary keys in your other tables.

You can set a new PK on the client side using Guid.NewGuid().

I think you are right, as I have had this issue thinking about it with a recursive save I did which did not do wuite as I thought. I have generated an integer primary key and made the guid an index. What I was trying to do was have some kind of security through obfuscation (is that the word confused ) its harder to guess a guid in a browser url than an integer number simple_smile

Thanks for your reply