Beispiel #1
0
 private static void InitializeSessionFactory()
 {
     try
     {
         _sessionFactory = Fluently.Configure()
                           .Database(MsSqlConfiguration.MsSql2012
                                     .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 <Visit>())
                           .Mappings(m => m.FluentMappings.AddFromAssemblyOf <Kid>())
                           .Mappings(m => m.FluentMappings.AddFromAssemblyOf <GenericVisitor>())
                           .Mappings(m => m.FluentMappings.AddFromAssemblyOf <Settings>())
                           .BuildSessionFactory();
     }
     catch (Exception e)
     {
         System.Console.WriteLine(e.StackTrace);
     }
 }
Beispiel #2
0
        public static void ResetDatabase()
        {
            try
            {
                _sessionFactory = Fluently.Configure()
                                  .Database(MsSqlConfiguration.MsSql2012
                                            .ConnectionString(
                                                (c => c
                                                 .Server(CustomizationManager.GetServer())
                                                 .TrustedConnection()
                                                 .Database(CustomizationManager.GetDatabase())
                                                 .Username("rodekors")
                                                 .Password("rodekors")))
                                            // .ShowSql()
                                            )
                                  .Mappings(m => m.FluentMappings.AddFromAssemblyOf <Visit>())
                                  .Mappings(m => m.FluentMappings.AddFromAssemblyOf <Kid>())
                                  .Mappings(m => m.FluentMappings.AddFromAssemblyOf <GenericVisitor>())
                                  .Mappings(m => m.FluentMappings.AddFromAssemblyOf <Settings>())
                                  .ExposeConfiguration(cfg => new SchemaExport(cfg)
                                                       .Create(true, true))
                                  .BuildSessionFactory();
            }
            catch (Exception e)

            {
                Console.WriteLine("NOOOOOO");
                Console.WriteLine(e.StackTrace);
            }
        }