Пример #1
0
		public static Bumble Through(string connectionString)
		{
			if (connectionStringToSessionFactoryCache.ContainsKey(connectionString))
				return new Bumble(connectionStringToSessionFactoryCache[connectionString].OpenSession());
			ISchemaInspector inspector = new SqlServerSchemaInspector(connectionString);
			Assembly assembly = CodeGenHelper.GenerateAssemblyAndMappingFromSchema(inspector);
			//Note that here we are not thread safe, can't create two session factories at the same time.
			AppDomain.CurrentDomain.TypeResolve += delegate(object sender, ResolveEventArgs args)
			{
				if (args.Name.StartsWith("Bumble"))
					return assembly;
				return null;
			};
			ISessionFactory sessionFactory = BuildSessionFactory(assembly, connectionString);
			connectionStringToSessionFactoryCache[connectionString] = sessionFactory;
			return new Bumble(sessionFactory.OpenSession());
		}
Пример #2
0
        public static Bumble Through(string connectionString)
        {
            if (connectionStringToSessionFactoryCache.ContainsKey(connectionString))
            {
                return(new Bumble(connectionStringToSessionFactoryCache[connectionString].OpenSession()));
            }
            ISchemaInspector inspector = new SqlServerSchemaInspector(connectionString);
            Assembly         assembly  = CodeGenHelper.GenerateAssemblyAndMappingFromSchema(inspector);

            //Note that here we are not thread safe, can't create two session factories at the same time.
            AppDomain.CurrentDomain.TypeResolve += delegate(object sender, ResolveEventArgs args)
            {
                if (args.Name.StartsWith("Bumble"))
                {
                    return(assembly);
                }
                return(null);
            };
            ISessionFactory sessionFactory = BuildSessionFactory(assembly, connectionString);

            connectionStringToSessionFactoryCache[connectionString] = sessionFactory;
            return(new Bumble(sessionFactory.OpenSession()));
        }