>> with AOP the problem is finding the root (it might be 5 levels deep). I was looking at Peter's suggestion but don't like what it requires. I am currently looking at a way to do this only in proxies but the trick is in finding out what aggregate root we are under while not having the id carried by the domain objects ... One thing I see is having the IHaveParentId be implemented by the proxy ... then have an IAggregateRoot for the actual parent ... so you can just keep walking up the path but none fo the objects carry the ids themselves. As I go through this though I keep hearing "too much magic" being whispered in my ear. <<
There is something I am not understanding about your problem, the problem I see is entirely different. Here is how I see your scenario where a new order is raised (the agg-root being order) and checking that the customer's limit isn't exceeded. using (var session = SessionFactory.OpenSession()) using (var transaction = session.BeginTransaction()) { var customer = CustomerRepository.Load(customerID, LockMode.Write); //Fetch a proxy only*** var newOrder = new Order(customer, ...................); //continue setting up the order ValidateTheOrder; customer.AcceptOrder(newOrder); session.Save(newOrder); transaction.Commit(); } The Order is validated, and the Customer is certain to not have been updated by another user. The part I have marked *** is the bit I see as the problem, and that is "How do I ensure nobody updates the customer?". Typically I would make sure the Customer is updated too but it seems in NH you can't force a version update on an object that is not dirty, so I am guessing that the LockMode is the solution, however I believe that is DB dependent and not all databases will support it. If it is in fact possible to update a non-dirty entity (to ensure agg-parts are valid) then you would add Session.Update(customer) too, but I suspect that is not possible. Is there something about your problem that I am missing? Pete --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---