Saving an Entity

Posts   
 
    
oq
User
Posts: 6
Joined: 17-Jun-2009
# Posted on: 18-Jun-2009 02:24:32   

I'm still relatively new to the product. I'm using v2.6.

If I create an entity and save it:

BankEntity bank = new BankEntity(); bank.AccountNumber = "1234567"; bank.Save();

Everything is fine of course. What I would then like to do is save the same entity again, or rather insert a new row and not update.

Besides creating a new BankEntity and copying the non-primary key values and issuing a save, is there a simple flag I can set to force an insert such that:

bank.Save();

Creates a new row in the table?

This is an oversimplified scenario but it captures the basic idea of what I'm trying to do.

Thanks!

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 18-Jun-2009 03:12:28   
bank.IsNew = true
....
bank.Save();

It's better (clean and legible) to initialize the entity:

bank = new BankEntity();
David Elizondo | LLBLGen Support Team