Updating an existing record in database will duplicate it.

Posts   
 
    
Nanako
User
Posts: 7
Joined: 21-Aug-2007
# Posted on: 12-Dec-2007 07:18:49   

Hi guys,

I'm using LLBLGen Pro version 2.5 final (Nov 5th,2007) to generate code with SelfService method. When I'm attempting to update an existing record in database, after update successfully, a duplicate record will be added into database. I usually use this way to do that and it works well, but except one table. I post the code I used here for reference


WorkDetailEntity entWork = new WorkDetailEntity();
entWork.FetchUsingPK(WorkDetailID);
entWork.WorkDate = DateTime.Now;
... 
...
entWork.Save();

Any idea for this?

Thanks in advance! Nanako.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 12-Dec-2007 10:14:09   

Have you by any chance set the entity's IsNew flag to true? Would you please post a complete code snippet?

After calling: entWork.FetchUsingPK(WorkDetailID); would you please check if (entWork.Fields.State == EntityState.Fetched) is true?