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
|
Hello, See the attached solution. It has single controller that inherits from LightSpeedControllerBase. The issue I'm having is that the model binder (LightSpeedEntityModelBinder) seems to provide an instance of MyEntity with an Id of 0 (zero), resulting in a new record being created rather than the existing record being modified. The URL and a hidden property has the Id but neither seem to do the trick. The Id is always 0. This seems to work with EF. I have spent a couple of hours on this and can't figure out what I'm doing wrong. Your assistance will be appreciated. Thanks, Werner |
|
|
The Id is currently ignored for now so you will always get a new entity. We are planning to improve this to match with the behavior you are looking for in the future but we need to implement a flexible approach that will allow the correct UnitOfWork to be discovered by the binder to allow it to try and load in any existing entity first. Currently if you want to update an existing entity you should take in just the Id argument to your action and then load the existing entity and then call UpdateModel<TEntity>(entity) which will perform the model binding based on the parameters that were passed in as part of the query.
Jeremy |
|
|
Thanks Jeremy, Have you guys ever considered to provide the infrastructure to generate things like the controllers, view models (and their mappers) and binders from the model? You may mitigate the about issue by just generating the binders for a specific UnitOfWork implementation. This may require that you allow more than one template to be specified in the model as well as the output path of that template. I can therefore register a template for a Controller and it may generate the code in my Web Application project rather than the data access library. I implemented my own binders in the meantime. Thanks, Werner
|
|