views:

85

answers:

1

I have the two following tables (SQL Server):

**IndexValues**
IdIndexValue int (PK)
Value varchar(2000)
IdIndex int (FK for Table Indexes)
IdDocument int (FK for Table Documents)


**IndexValuesLists**
IdIndexValueList int (PK)
IdIndexValue int (PK with IdIndexValueList, FK for Table Indexes)

Explaining a little, the second table groups items from the first table. A document can have various "group items" at the second table. I have the following BusinessObjects classes:

IndexValue {
int Id;
string Value;
Document Document;
Index Index;
}

IndexValueList {
int Id;
Document Document;
List<List<IndexValue>> IndexesValues;
}

I don't know how to do the mapping for this last property. How to do that on the hbm.xml ?

EDIT: Making an example for explaining more what I need:

IndexValues rows:

IdIndexValue / Value / IdIndex / IdDocument

1, "A", 10, 500
2, "Circle", 11, 500
3, "John", 12, 500

4, "B", 10, 500
5, "Square", 11, 500
6, "Mary", 12, 500

======================

IndexValuesLists rows:

IdIndexValueList  / IdIndexValue

1, 1
1, 2
1, 3
2, 4
2, 5
2, 6
+1  A: 

List-of-lists does not seem like the kind of thing NHibernate would support out of the box. (If if really means that much to you, of course, you are free to implement support for this scenario yourself.)

Deeper than that, your domain model seems a little too strange. Why do you have a list-of-lists of index-values? Perhaps you need a new domain entity which has a list of index-values, and a replace the list-of-lists with a list of this new domain entity?

Justice
Sure, it is an option. I can't change how the things are done at database, but if I could create a IndexValuesGroup class and do the mapping I need, List-of-lists would not be necessary, but I thought it was more difficult than do the list-of-lists thing. Thanks for the reply ;)
Victor Rodrigues