I am needing to create a named-query, and use it with one of the maps, that i currently have defined as a fluent map.
is it possible to continue using the fluent map, and be able to create the named-query dynamically in code? or, is switching to a hbm map the only option?
Maybe I'm misreading the question, but you don't have to switch to hbm mapping completely.
You could continue to use fluent NHibernate to map classes and use hbm for named queries only. In your configuration, you'd then include the entities and the hbms.
_sessionFactory = Fluently.Configure()
.Mappings(m =>
{
m.FluentMappings.AddFromAssemblyOf<SomeEntityMap>();
m.HbmMappings.AddFromAssemblyOf<SomeEntityMap>();
})
.BuildSessionFactory();
In your namedQueries.hbm.xml you then only define named queries:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<query name="Some.Query.Of.Yours">
<![CDATA[
from SomeEntity e
where e.Property = :propertyValue
]]>
</query>
</hibernate-mapping>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With