views:

68

answers:

1

create table Table1(attributeName varchar(100), attributevalue varchar(100), attributeLookupMethod varchar(50))

create table Table2(attributeName varchar(100), CSVAllowableValues varchar(1000)

Based on the above 2 tables, using nHibernate, is it possible to only retrieve details from Table2 when Table1.attributeLookupMethod = 'Lookup'?

Thanks.

+2  A: 

Implement subclassing in your two tables.

You'll have a class for Table1, and a class for Table2 which will extend the first one. In Table1 mapping declare the field 'attributeLookupMethod' as discriminator. In the mapping for subclass Table2 declare the discriminator-value as 'Lookup'.

NHibernate doc about subclassing

By doing this it might be good to declare a common primary key (maybe attributeName) and a foreign key from Table2 to Table1

victor hugo
That FK needs to be between the PK of Table2 -> PK of table1 ;)
Frans Bouma
You're right. I added this to the answer. Thanks
victor hugo