This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, I already read advices and considerations about modifing id. For some reason artificial id's are not an option. But one thing could probably be improved inside LightSpeed with relatively small effort: It seems for new row (as long as it is not added to unit of work and id was not yet changed) it is possible to assign any id. But condition seems to be too restrictive - it is only possible to change this id once, consecutive changes causes an exception. Wouldn't it be better if this condition will check EntityState instead of checking original field content? Because if it is possible to create Id for newly added row, it should be also possible to change it as long as it is not saved in database. At the moment I had to create workaround with artificial Id field which updates real Id field on event Saving. But I have to store newly created rows outside of unit of work, otherwise GenerateId is called, which destroys possibility of further Id updates. It is not nice, and has also ugly side effect, that in case of validation problems field becomes read-only again. Greetings |
|
|
We dont intend Id to be modified once it has been assigned which is why its a read-only property. The entity being persisted is not really a factor here as there can be relationships which exist between new entities within the current UnitOfWork scope. What are you looking to do which would need a change of an identity value?
|
|
|
Unfortunatelly for me I have to agree. And generaly this behaviour is better. What we want to achieve is relatively simple. We have grid based editor where we allow to edit more than one row at the same time. It's better while it is a tool for editing database configuration entries for admins. Submiting changes is done on pressing save button. And the problem comes when you add new row into a grid, because we would like to let users also change id before row is submited. We are unfortunately using also composite keys (it is more human readable in configuration). Anyway, maybe I will just publish my workaround in case anybody meets the same problem: We override GenerateId function, and we created additional properties for id columns for binding inside a grid:
|
|