Question

I have a table that needs relations to 2 tables, according to ObjectType column.

For example if ObjectType=1 then column Object should point to TABLE1, and if ObjectType=2 then point to TABLE2.

Can I accomplish this in NHibernate mappings or as Fluent NHibernate?

If not will you suggest me using same Interfaces for both Table classes? (Note: table schemas are totally different)

Was it helpful?

Solution

Why not reference both tables, and use one or the other according to your needs in the class code? Use a property that returns a common interface for both tables and gives one table or the other according to the object type.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top