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

Loquacious configuration


Loquacious configuration is the latest addition to the family of configuration options that NHibernate comes bundled with and it is the best option so far. Loquacious offers a code based and easy to infer API for configuring NHibernate. Parts of the API are also fluent which makes it less verbose to work with. Loquacious API is built by extending the programmatic configuration API and hence can be called a part of programmatic configuration. Without much ado, let's jump straight into the code:

public class LoquaciousConfiguration
{
  private readonly ISession session;

  public LoquaciousConfiguration()
  {
    var config = new Configuration();
    config.DataBaseIntegration(db =>
    {
      db.Dialect<SQLiteDialect>();
      db.Driver<SQLite20Driver>();
      db.ConnectionString = "data source=:memory:";
      db.ConnectionReleaseMode =
      ConnectionReleaseMode.OnClose;
      db.LogSqlInConsole = true;
      db.LogFormattedSql = true;
    })
 ...