This project is read-only.

Initial ID

Nov 3, 2011 at 12:48 PM


A question regarding initial id on a DTO.
I have a DTO, Arena, wich is to be persisted in database.
Initially the property ID wich is the PK is set to 0 - (this might be wrong?) - but should I set some other property in the model as well on the PK (Generated = True, ComputedColumn = False, AllowNull = false, Identity = None, IsUniq = True, PrimaryKey=True)?
What happens now is that, when calling persist, it will try to find a record with id 0 and if it exist it will be updated - the same record is updated again and again...
How do I indicate that a record is new?



Nov 4, 2011 at 4:34 PM

It seems to me that you have not specified what will control your Identity Field, and you expect something to take care of it.  If you choose Identity None, you must set find out what the next ID would be manually and set it that way.

Generally I set Identity to Database, and a call to Collection.NewItem() will generate the next PK.  I think the same will happen if you were to set Identity = Code.


Is this the answer that you are looking for?


Nov 13, 2011 at 1:49 PM

If you set Identity to true then the value will be auto-generated. If you set it to None as stated, the value you specify will be the value used.