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, The documentation says: to update an entity, set the required properties to the new values: "Updating an Existing Entity To update an existing entity, load it into a unit of work and set any required properties to their new values. Customer customer = unitOfWork.FindById LightSpeed automatically determines that the entity has changed, and marks it to be saved." Is there anyway to update the whole entity, rather than having to specify every property. Would be very tedious for an Entity (containing 200 properties) with say, 100 properties that have changed. My scenario is an MVC3 project - user updates "n" properties of an Entity -> click submit button -> model passed to controller, where Entity is instantiated: customer. Rather than doing: customer.a=model.a; customer.b=model.b etc I have tried: customer = model; unit of work (uow) updates correctly -> shows the customer Entity is updated with changed properties. However, uow.saveChanges() does not update the underlying database record. Nothing happens to the record, and not even a new record is created. Thanks |
|
|
Hi Douglas, You dont need to explicitly set the properties for LightSpeed to track them, they are automatically tracked so any property assignment is fine and what you have described with your MVC example is also fine but it sounds like you have not associated the entity with the UnitOfWork. If your entity is being automatically created by MVC (e.g. its an method parameter to your controller action) then you will need to call UnitOfWork.Add() to add it to the UnitOfWork so that it will get saved. Keep in mind that if you are dealing with existing entities you should pass in the Id of the entity you are working with to the action method and then load that (e.g. var entity = UnitOfWork.FindById
|
|