How to enable auto-import = "true" when we use Nhibernate 3.2 to display by code?

I need to use the HQL query in my project, and I have the error: "entity is not displayed."

When I read nHibernate HQL - the entity is not displayed or nHibernate HQL - the entity is not displayed (or another website). I can read that I need to use auto-import = "true" for each class.

<hibernate-mapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" namespace="BusinessObjets" assembly="BusinessObjects" xmlns="urn:nhibernate-mapping-2.2" auto-import="true"> ... 

How can we configure this automatic import when we use code matching with nhibernate 3.2?

I use this code to load the display:

 var mapper = new ModelMapper(); mapper.AddMappings(typeof(Repository).Assembly.GetTypes()); return mapper.CompileMappingForAllExplicitlyAddedEntities(); 

Hi

+6
source share
1 answer

You cannot set it directly in the mapping, but you can modify the HbmMapping object returned by the CompileMappingForAllExplicitlyAddedEntities method before passing it to the Configuration object:

 mapping.autoimport = true; 
+7
source

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


All Articles