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
|
Using LightSpeed version 4.0.1534.21185 professional with VS 2010 and SQL 2008 in MVC 4 application. LightSpeedEntityModelBinder.Register(typeof(MyModelUnitOfWork).Assembly); is in gloabal.asax. I have a situation that I am unable to figure out what is happening, or if I am not doing something correctly. I have an entity that looks like the following, both a view model and a LightSpeed generated model
I retrieve the LS model from the database and map it to the view model and it displays fine. I update the parent and post changes and everything is fine. It updates the LockVersion and save the changes. The problem is when I try to update the child entity, it gets the lock version from the parent entity and then I get a concurrency error. Basic st ps in the process are as follows:
foreach (var editItem in ViewModel.ChildEntities) {
uow.SaveChanges(); When UpdateModel is called on the child model, the lock version of the child model is updated to the LockVersion of the ParentModel and the EntityState is changed to Modified, but none of the other properties are updated in the child model. Then the lock version is usually incorrect and throws the error. Hopefully, it is just something simple I am missing, but I have tried multiple different ways of trying to get this to work. Thanks for the help. |
|
|
I think I figured out what was happening here. It had to do with how the view was setting the LockVersion when there are multiple models in the view and tehrefore multiple LockVersions. I do still have a question about how LockVersion is supposed to work. I get a model back from the edit post and it has a LockVersion. I get the domain model from the database, and call UpdateModel, but even if the view model LockVersion is different from the domain model LockVersion, it will allow the changes to be saved. Is UpdateModel supposed to change the LockVersion of the domain model during UpdateModel? I am not quite sure what I should expect so that I can program accordingly. Thanks |
|
|
Thanks for the added detail - LockVersion could be set given the way in which the binder is implemented but it shouldn't set that field since it will only lead to issues. Ive added in a check for managed fields and this should be merged in for the nightly builds tomorrow. I will update this once this has happened :)
|
|