Book Image

Learning NHibernate 4

Book Image

Learning NHibernate 4

Overview of this book

Table of Contents (18 chapters)
Learning NHibernate 4
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Fluent configuration


If you are using FNH for declaring mappings, then loquacious configuration is not an option. This is mainly because loquacious configuration would not be able to recognize fluent mappings. Besides that, FNH offers its own fluent API to configure session factory. The fluent API is more or less similar to loquacious API in terms of functionality offered. But fluent API tries to be less verbose as compared to loquacious. Let's do the same configuration we did using loquacious configuration, but using fluent API this time:

var fluentConfig = Fluently.Configure()
.Database(SQLiteConfiguration.Standard.InMemory()
                             .ShowSql().FormatSql())
.Mappings(mapper =>
{
  mapper.FluentMappings.Add<EmployeeMappings>();
  mapper.FluentMappings
  .Add<CommunityMappings>();
  mapper.FluentMappings.Add<BenefitMappings>();
  mapper.FluentMappings.Add<LeaveMappings>();
  mapper.FluentMappings.Add<SkillsEnhancementAllowanceMappings&gt...