Fluent NHibernate Has Been Released as 1.0 RC
James Gregory, the owner of the Fluent NHibernate project, has announced his project has reached the 1.0 milestone and it is currently a Release Candidate.
The Release Notes mention the following features and improvements in the mapping section:
- Cleaned up method names - Removed a lot of noise in method names, such as WithLengthOf is now just Length; ColumnName to Column, WithTableName to Table etc...
- Removed SetAttribute - SetAttribute was a stop-gap measure to allow people to use Fluent NHibernate when we didn't support the attributes they needed. We've now gone to a great length to support all of the main attributes in the fluent interface, so you shouldn't need this anymore. If there are any attributes you need that we've missed, let us know (or even better, send us a pull request/patch)
- Separated subclass mapping - Subclasses can (and should be) defined separately from their parent mapping. Use SubclassMap<T> the same way as you would ClassMap<T>; if the top-most mapping (ClassMap) contains a DiscriminateSubclassesOnColumn call, the subclasses will be mapped as table-per-class-hierarchy, otherwise (by default) they'll be mapped as table-per-subclass.
See subclasses for more info.
- Renamed the static entry point -
AutoPersistenceModel.MapEntitiesFromAssemblyOf<Product>was always a bitwordy, it's been renamed to
- Components - Improved support for components in automapping. They still work the same as before but now have support for all the collections and things they should have.
See components for more info.
- IgnoreProperty for all types - You can now use IgnoreProperty against multiple types, instead of on a per-entity basis.
See ignoring properties for more info.
In the conventions section we find:
- Always applied first - They're now applied before any of your explicit settings in your ClassMap. This means that there's no accidently overwriting your mappings.
- Always apply by default - Conventions used to have an Accept method that most people just either returned true, which meant apply to everything, or checked if a value had been set in the ClassMap; considering the above change, this meant Accept was mostly redundant. Conventions now always apply to everything. If you don't want that, there's an IClassAcceptance (and equivilant for other conventions) interface to add this behavior
- Acceptance Criteria - For when you do need an Accept defined, there's a new criteria API for defining it in a much more consistent manner.
See acceptance criteria for more info.
- ForeignKeyConvention - Base-class provided for setting the foreign-key naming consistently across the whole of your mappings.
See ForeignKeyConvention for more info.
- ManyToManyTableNameConvention - Base-class (and defaults) for setting the table name of many-to-many's. This is much smarter than it was before, no overwriting explicit settings, support for bi-directional relationships.
See ManyToManyTableNameConvention for more info.
Gregory hopes the project won’t stay long as RC considering the amount of testing already put into it.
Fluent NHibernate offers an alternative to using XML by providing fluent mappings through C# code. It also provides auto-mapping which uses a mechanism creating the mappings directly from entities. A quick introduction to Fluent NHibernate can be found on InfoQ/Fluent NHibernate. More details are available on Fluent NHibernate Wiki page. The Downloads page contain both the sources and the binaries for those who want to try it out.
Does it support multiple mappings per table or per class?
Randy Shoup Jul 03, 2015