private static ISessionFactory BuildSessionFactory(CommandConnectionString connectionString) { FluentConfiguration configuration = Fluently.Configure() .Database(MsSqlConfiguration.MsSql2012.ConnectionString(connectionString.Value)) .Mappings(m => m.FluentMappings .AddFromAssembly(Assembly.GetExecutingAssembly()) .Conventions.Add( ForeignKey.EndsWith("ID"), ConventionBuilder.Property.When(criteria => criteria.Expect(x => x.Nullable, Is.Not.Set), x => x.Not.Nullable())) .Conventions.Add <OtherConversions>() .Conventions.Add <TableNameConvention>() .Conventions.Add <HiLoConvention>() ); return(configuration.BuildSessionFactory()); }
public SessionFactory(CommandConnectionString connectionString) { _factory = BuildSessionFactory(connectionString); }