示例#1
0
        private static void InitializeSessionFactory()
        {
            try
            {
                _sessionFactory = Fluently.Configure()
                                  .Database(MsSqlConfiguration.MsSql2008
                                            .ConnectionString(
                                                (c => c
                                                 .Server(CustomizationManager.GetServer())
                                                 .TrustedConnection()
                                                 .Database(CustomizationManager.GetDatabase())
                                                 .Username("rodekors")
                                                 .Password("rodekors")))
                                            .ShowSql()//Uncomment denne for å få output
                                            )
                                  .Mappings(m => m.FluentMappings.AddFromAssemblyOf <Vare>())
                                  .Mappings(m => m.FluentMappings.AddFromAssemblyOf <Salg>())
                                  .Mappings(m => m.FluentMappings.AddFromAssemblyOf <Logg>())
                                  .Mappings(m => m.FluentMappings.AddFromAssemblyOf <Settings>())
                                  .Mappings(m => m.FluentMappings.AddFromAssemblyOf <Users>())
                                  .Mappings(m => m.FluentMappings.AddFromAssemblyOf <UserLogg>())

                                  .BuildSessionFactory();
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.StackTrace);
            }
        }
示例#2
0
 public static void ResetDatabase()
 {
     _sessionFactory = Fluently.Configure()
                       .Database(MsSqlConfiguration.MsSql2008
                                 .ConnectionString(
                                     (c => c
                                      .Server(CustomizationManager.GetServer())
                                      .TrustedConnection()
                                      .Database(CustomizationManager.GetDatabase())
                                      .Username("rodekors")
                                      .Password("rodekors")))
                                 .ShowSql()
                                 )
                       .Mappings(m => m.FluentMappings.AddFromAssemblyOf <Vare>())
                       .Mappings(m => m.FluentMappings.AddFromAssemblyOf <Salg>())
                       .Mappings(m => m.FluentMappings.AddFromAssemblyOf <Logg>())
                       .Mappings(m => m.FluentMappings.AddFromAssemblyOf <Settings>())
                       .Mappings(m => m.FluentMappings.AddFromAssemblyOf <Users>())
                       .Mappings(m => m.FluentMappings.AddFromAssemblyOf <UserLogg>())
                       .ExposeConfiguration(cfg => new SchemaExport(cfg)
                                            .Create(true, true))
                       .BuildSessionFactory();
 }