0
votes

I have a legacy database that contains three entities in one table - Category, Product, and Variant to be precise. There is a column called ClassType that defines which entity the row belongs to (1=Category, 2=Product, 3=Variant).

How do I translate that to a (Fluent) NHibernate mapping?

For example, I have a unit test Can_get_products_in_category. When I run the test and look at the SQL it returns the products but also the categories. Is there a way to say "only return ids with ClassType = x"?

I should say that I also have a Hierachry table that just contains the Id and child Ids for both Categories, child categories, and products.

I'm fairly new to (Fluent) NHibernate.

1

1 Answers

1
votes

I'm afraid I am not a fluent NHibernate user, but in the NHibernate XML mapping you could add a 'where' attribute to filter out the rows that belong to the mapped entity class. Fluent NHibernate should provide an equivalent attribute to achieve the same effect.

Cheers, Gerke.