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, Say I have an Order, that contains one OrderLine. If I do unitOfWork.Delete(OrderLine), then immediately the OrderLine vanishes from Order.OrderLines. So far so good... ... but OrderLine.Order is not null (as I would expect), instead it still points to the Order. Is the reasoning behind this behavior that, since I just deleted the OrderLine, who cares about its properties? I guess that makes sense, although it does violate my intutive assumption both ends of an association are always consistent with each other. Anyway, just thought I'd ask for some clarification about what the rationale is. (And, by the way, is there any switch that I could set to get the behaviour that I want? :-) |
|
|
The reasoning is basically as you described, we dont care about the properties of the entity because it is now flagged as deleted. The only persistance operation that will occur here is to remove it from the database. When you call UnitOfWork.Remove() we set the EntityState to Deleted. All of the EntityCollection's that this entity has been added into will be notified about this (they listen on EntityStateChanged) and when they see an entity move to EntityState.Deleted they remove them from their collection, the entity itself takes no action on moving into the Deleted state. Hopefully this gives some clarify on the behaviour you are seeing :)
|
|
|
Thanks Jeremy. That gave me the pointer I needed - now my in-memory fake database gives the same behaviour as when we are really using Lightspeed, simply by setting EntityState in the fake case, using the very handy EntityFactory. John |
|