Nhibernate asks for all objects that implement the interface.

For example, if you have Apple: IWhatever and Orange: IWhatever, and you want to find both of them because they are IWhatevers, what do you need to do in NHibernate?

Is this completely dependent on the HQL query or criteria, or is there something you should do in the mapping too? If there is a display requirement, can Fluent NHibernatee support it?

+3
source share
2 answers

You can do UnionSubClass mapping. Unfortunately, it is not supported in Fluent.

The display will look something like this:

<class name="IWhatever" abstract="true">
    <id name="Id">
    </id>

    <union-subclass name="Apple">
        <property name="Bla" type="int"/>
    </union-subclass>

    <union-subclass name="Orange">
        <property name="Bla" type="int"/>
    </union-subclass>
</class>
+1
source

In terms of criteria, you do not need to display it. Simply:

session.CreateCriteria<IWhatever>()
       .List<IWhatever>();

, // , IWh .

+4

Source: https://habr.com/ru/post/1762526/


All Articles