NHibernate mapping

  • Thread starter Thread starter David Veeneman
  • Start date Start date
D

David Veeneman

I'm relatively new to NHibernate, and I am trying to figure out how to map a
collection. I know how to map a collection that is held directly by a parent
class, such as an Order class with an OrderItems property that is a
List<OrderItem>. But what if the collection is held in an intermediate
class?

For example, what if I want to add some intelligence to my list of order
items? In that case, I might have an Order class with an OrderItems property
that is class of type OrderItems. The OrderItems class would have an Items
property that is a List<OrderItem>, along with other properties that provide
information about the list, such as number of items delivered, number of
items on hold, and so on.

I'm not sure how I would map this relation. The Order class is persisted,
but it looks like the OrderItems class wouldn't be. And it looks like the
OrderItem class (the individual order items in the list) would be. How would
I map this overall relation in NHibernate?

Thanks in advance for your help.

David Veeneman
Foresight Systems
 
I may have my answer. My OrderItems class is derived from List<T>; it's
basically a List<T> with some computed properties added to it. So the
mapping would be a one-to-many association from Order to OrderItem, just as
if the OrderItem objects were held in a List<T>.

Please let me know if I'm wrong on this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top