filters is the way to go here. you can (dis)enable them per session to get a clean domain. Where clauses are permanent, filters are not. there is an article or 2 on nhforge wiki about filters. ayende and fabio (i think) also have posts about filters on their respective blogs.
another option is to have a separate entities for orders. I have heard of this approach with larger e-commerce models. instead of a status flag and property to determine the status of the order, you have entire entity aggregates for each of the different statuses. each status has it's own set of behavior that is completely independent of the other statuses. they are usually something like Shopping Cart Order Invoice CancelledOrder On Nov 13, 11:33 am, Kevin Pang <[email protected]> wrote: > Let's say I have an e-commerce application where a User can have > multiple Orders. Let's say that in this domain, a User can cancel his/ > her Order which changes its status from "Pending" to "Canceled". The > only thing that distinguishes a "Pending" Order from a "Canceled" > Order in the database is this status flag. > > Now, let's say that "Canceled" Orders don't need to be displayed too > often. It seems reasonable that my User object might want two lazy- > loaded lists, one for the User's "Pending" Orders and one for the > Users's "Canceled" Orders. It sounds like I can do this using the > "where" attribute on the "map" element of my NHibernate mappings > (basically having two one-to-many > > If I wanted my domain model to contain, say, a lazy-loaded list for > his current Orders as well as a lazy-loaded list of his past Orders, > would that be possible using NHibernate? > > Secondly, if it is possible and I wanted to add a "CancelOrder" > function to my User class, what would it do? Looking at it from the > domain's perspective, it feels like I should find the correct Order > from the "Pending" list, change its status to "Canceled", and move it > to the "Canceled" list. Will NHibernate be smart enough to figure out > how to persist that? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
