Is it possible to generate table indexes along with the rest of the database schema with Fluent NHibernate? I would like to be able to generate the complete database DDL via an automated build process.
相关问题
-
NHibernate Query
with detached criteria… - Fluent NHibernate automap PostGIS geometry type
- Using NHibernate to execute DDL statements
- Setting Linq to NHibernate ADO Command Timeout
- NHibernate: many-to-one and lazy
相关文章
- Fluent NHibernate — Saving Entity with Composite K
- Is this the right way of using ThenFetch() to load
- Can Persistence Ignorance Scale?
- How to find if a referenced object can be deleted?
- Null value objects in NHibernate
- NHibernate SQL query slow
- Fluent nHibernate automapping property as nvarchar
- NHibernate: How to perform eager subselect fetchin
Do you mean indexes on columns?
You can do it manually in your
ClassMap<...>
files by appending.SetAttribute("index", "nameOfMyIndex")
, e.g. like so:or you can do it by using the attribute features of the automapper - e.g. like so:
After having created your persistence model:
and then do this to your entities:
I like the latter. Is is a good compromise between not being non-instrusive to your domain model, yet still being very effective and clear on what is happening.
In more recent versions of Fluent NHibernate, you can call the
Index()
method to do this rather than usingSetAttribute
(which no longer exists):Mookid's answer is great and helped me a lot, but meanwhile the ever evolving Fluent NHibernate API has changed.
So, the right way to write mookid sample now is the following:
where IndexedPropertyConvention is the following:
The [Indexed] attribute works the same way now.