views:

256

answers:

2

Hi,

I have the following DB Table

CREATE TABLE ProductPrice
  ProductID
  Qty1
  Price1
  Qty2
  Price2
  Qty3
  Price3

My domain classes look like this

Class ProductPrice
  ProductID As Integer
  PriceBands As IList(of PriceBand)
End Class

Class PriceBand
  Qty As Integer
  Price As Decimal
End Class

I know we can use the "component" mapping to map a single row into different objects but is it possible to map a collection of objects as described above?

Many Thanks

James

A: 

I think seeing 1,2,3 at the end of field names is usually a sign of bad database design so I'd be kind of surprised if NH supported this.

ShaneC
As I said above I can't change the table design. Is there a way to do a manual mapping at all?
James
A: 

if you can, normalize your database into two tables - products and product prices (each row containing product ID, quantity and price band for that quantity, insead having them like 3 pairs of columns). then you will easily map them as collections (bags) in NHibernate to match your application model classes.

zappan