예제 #1
0
        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());
        }
예제 #2
0
 public SessionFactory(CommandConnectionString connectionString)
 {
     _factory = BuildSessionFactory(connectionString);
 }