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
|
I have a list of entities that are interconnected, and some of them have a invalid state (from a business logic point of view). My problem is that when I save the valid entities the invalid entities are also saved. I don't call attach on the invalid entities, but it seems to me that if there is a relation like this valid entity <- Fk other valid entity -> invalid entity then when I attach the valid entity, it's Fk entity is also attached together with the invalid entity. Is there a way to explicitly specify what should be saved? I use the 4.0.797.18460 build from 2011-10-27. |
|
|
When you attach an entity any associations will also get enlisted in the UnitOfWork (attached), if the associations are lazy and not loaded then these will not be loaded in so this is only going to be an issue if the associations have been loaded or you are have manually assigned them prior to attaching the primary entity to the UnitOfWork. When saving the UnitOfWork, all entities enlisted in the UnitOfWork are considered for persistance to ensure consistency, so assuming there has been a modification or its a new entity then LightSpeed will attempt to persist it. Are you using validation to express your business rule concerns? LightSpeed will raise an error if you attempt to persist an entity in an invalid state so that would avoid the problem with persisting invalid entities.
|
|