當前位置: 首頁>>代碼示例>>C#>>正文


C# Configuration.AddAssembly方法代碼示例

本文整理匯總了C#中NHibernate.Cfg.Configuration.AddAssembly方法的典型用法代碼示例。如果您正苦於以下問題:C# Configuration.AddAssembly方法的具體用法?C# Configuration.AddAssembly怎麽用?C# Configuration.AddAssembly使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NHibernate.Cfg.Configuration的用法示例。


在下文中一共展示了Configuration.AddAssembly方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Setup

		public void Setup()
		{
			_cfg = new Configuration();

			_cfg.SetProperty("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
			_cfg.SetProperty("connection.driver_class", "NHibernate.Driver.SqlClientDriver");
			_cfg.SetProperty("connection.connection_string", _connectionString);
			_cfg.SetProperty("dialect", "NHibernate.Dialect.MsSql2005Dialect");
			_cfg.SetProperty("default_schema", "bus");
			_cfg.SetProperty("show_sql", "true");
			_cfg.SetProperty("proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle");

			_cfg.AddAssembly(typeof(NHibernateSagaRepository<>).Assembly);
			_cfg.AddAssembly(typeof(RegisterUserStateMachine).Assembly);
			_cfg.AddAssembly(typeof(When_using_the_saga_locator_with_NHibernate).Assembly);

			ISessionFactory _sessionFactory = _cfg.BuildSessionFactory();

			LocalContext.Current.Store(_sessionFactory);

			NHibernateUnitOfWork.SetSessionProvider(() => LocalContext.Current.Retrieve<ISessionFactory>().OpenSession());

			UnitOfWork.SetUnitOfWorkProvider(NHibernateUnitOfWork.Create);

			_sagaId = CombGuid.Generate();

		}
開發者ID:KevM,項目名稱:MassTransit,代碼行數:27,代碼來源:SagaLocator_Specs.cs

示例2: MainWindow

    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();

        Configuration configuration = new Configuration();
        configuration.Configure ();
        configuration.SetProperty(NHibernate.Cfg.Environment.Hbm2ddlKeyWords, "none");
        configuration.AddAssembly(typeof(Categoria).Assembly);
        configuration.AddAssembly(typeof(Articulo).Assembly);

        new SchemaExport(configuration).Execute(true, false, false);

        ISessionFactory sessionFactory = configuration.BuildSessionFactory ();

        //updateCategoria(sessionFactory);

        //insertCategoria(sessionFactory);

        //loadArticulo(sessionFactory);

        ISession session = sessionFactory.OpenSession();
        ICriteria criteria = session.CreateCriteria (typeof(Articulo));
        criteria.SetFetchMode("Categoria", FetchMode.Join);
        IList list = criteria.List();
        foreach (Articulo articulo in list)
            Console.WriteLine("Articulo Id={0} Nombre={1} Precio={2} Categoria={3}",
                              articulo.Id, articulo.Nombre, articulo.Precio, articulo.Categoria);

        session.Close();

        sessionFactory.Close ();
    }
開發者ID:esterdam,項目名稱:ad,代碼行數:33,代碼來源:MainWindow.cs

示例3: GenerateDatabaseSchema

 /// <summary>
 /// Generates the required schema in the project database
 /// </summary>
 public static void GenerateDatabaseSchema()
 {
     Configuration config = new Configuration();
     config.Configure();
     config.AddAssembly(typeof(PhoneNumber).Assembly);
     config.AddAssembly(typeof(Person).Assembly);
     
     SchemaExport exporter = new SchemaExport(config);
     exporter.Execute(false, true, false);
 }
開發者ID:JHardin1112,項目名稱:winforms-mvp-example,代碼行數:13,代碼來源:SchemaGenerator.cs

示例4: NHConfig

        static NHConfig()
        {
            var modelAssembly = typeof(Zza.Model.Customer).Assembly;
            var mappingAssembly = typeof(NHConfig).Assembly;

            // Configure NHibernate
            _configuration = new Configuration();
            _configuration.Configure();  //configure from the app.config
            _configuration.AddAssembly(modelAssembly);
            _configuration.AddAssembly(mappingAssembly);

            _sessionFactory = _configuration.BuildSessionFactory();
        }
開發者ID:Cosmin-Parvulescu,項目名稱:Breeze,代碼行數:13,代碼來源:NHConfig.cs

示例5: Setup

        public void Setup()
        {
            _cfg = new Configuration();

            _cfg.SetProperty("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
            _cfg.SetProperty("connection.driver_class", "NHibernate.Driver.SqlClientDriver");
            _cfg.SetProperty("connection.connection_string", _connectionString);
            _cfg.SetProperty("dialect", "NHibernate.Dialect.MsSql2005Dialect");
            _cfg.SetProperty("default_schema", "bus");

            _cfg.AddAssembly(typeof (NHibernateSagaRepository<>).Assembly);
            _cfg.AddAssembly(typeof (RegisterUserStateMachine).Assembly);
            _cfg.AddAssembly(typeof (SagaRepository_Specs).Assembly);
        }
開發者ID:vinayreddym,項目名稱:MassTransit,代碼行數:14,代碼來源:SagaRepository_Specs.cs

示例6: Gerar_schema

 public void Gerar_schema()
 {
     var cgc = new Configuration();
     cgc.Configure();
     cgc.AddAssembly("Comercio.Mapeamento");
     new SchemaExport(cgc).Execute(false, true, false);
 }
開發者ID:nielson266,項目名稱:Comercio,代碼行數:7,代碼來源:ConfigNHibernate.cs

示例7: generate

 public void generate()
 {
     var cfg = new Configuration();
     cfg.Configure();
     cfg.AddAssembly(typeof(Question).Assembly);
     new SchemaExport(cfg).Execute(false, true, false);
 }
開發者ID:ryselis,項目名稱:viktoro_viktorina,代碼行數:7,代碼來源:DatabseTests.cs

示例8: RunSample

        private static void RunSample(int sampleToRun)
        {
            var cfg = new Configuration();
            cfg.AddAssembly(typeof(Customer).Assembly);

            using (ISessionFactory factory = cfg.BuildSessionFactory())
            {
                DatabaseCleaner.ClearDatabase(cfg, factory);

                switch (sampleToRun)
                {
                    case 1:
                        Save_Load_and_Delete_Example.Run(factory);
                        break;
                    case 2:
                        Save_MTO_And_Lazy_Load_Example.Run(factory);
                        break;
                    case 3:
                        CRUD_with_Collections.Run(factory);
                        break;
                    case 4:
                        Querying_Examples.Run(factory);
                        break;
                    default:
                        Console.WriteLine("Unknown sample {0}. Please try another", sampleToRun);
                        break;
                }
            }
        }
開發者ID:diabluchanskyi,項目名稱:pablo,代碼行數:29,代碼來源:Sample_Executor.cs

示例9: InitConfiguration

 public static Configuration InitConfiguration()
 {
     Configuration = new Configuration();
     Configuration.Configure(@"Config\NHibernate.cfg.xml");
     Configuration.AddAssembly("Org.Limingnihao.Application");
     return Configuration;
 }
開發者ID:limingnihao,項目名稱:Net,代碼行數:7,代碼來源:NHibernateHelper.cs

示例10: TestClassSetup

 public static void TestClassSetup(TestContext context)
 {
     _configuration = new Configuration();
     _configuration.Configure();
     _configuration.AddAssembly(typeof(Draft).Assembly);
     _sessionFactory = _configuration.BuildSessionFactory();
 }
開發者ID:Snidd,項目名稱:RotisserieDraft,代碼行數:7,代碼來源:TestMemberRepository.cs

示例11: GetAll

        public IList<INotification> GetAll()
        {
            // webbikäyttöön
            // App_Start.NHibernateProfilerBootstrapper.PreStart();

            // konsolissa
            // NHibernateProfiler.Initialize();

            IList<INotification> notifications;
            var cfg = new Configuration();
            cfg.DataBaseIntegration(x =>
                {
                    x.ConnectionString = "Server=localhost;Database=NHibernateDemo;Integrated Security=SSPI;";
                    x.Driver<SqlClientDriver>();
                    x.Dialect<MsSql2008Dialect>();
                    //x.LogFormattedSql = true;
                    //x.LogSqlInConsole = true;
                });
            cfg.SessionFactory().GenerateStatistics();
            cfg.AddAssembly(Assembly.Load("Domain"));
            var sessionFactory = cfg.BuildSessionFactory();
            var session = sessionFactory.OpenSession();
            var notificationsQueryable =
                from customer in session.Query<INotification>()
                //where customer.FirstName.Contains("e")
                orderby customer.FirstName
                select customer;
            notifications = notificationsQueryable.ToList();
            return notifications;
        }
開發者ID:puuparta,項目名稱:miscellaneous_work,代碼行數:30,代碼來源:NotificationRepository.cs

示例12: button3_Click

 private void button3_Click(object sender, EventArgs e)
 {
     var cfg = new Configuration();
     cfg.Configure();
     cfg.AddAssembly(typeof(Domain.User).Assembly);
     var sessions = cfg.BuildSessionFactory();
     var sess = sessions.OpenSession();
     var login = textBox1.Text;
     IQuery q = sess.CreateQuery("FROM User u where u.Login=:login").SetParameter("login",login);
     var list = q.List<Domain.User>();
     if (list.Count > 0 && list[0].Pass == textBox2.Text)
     {
         var role_id = list[0].Role_id;
         IQuery q_role = sess.CreateQuery("FROM Role u where u.Id=:role_id").SetParameter("role_id", role_id);
         var list_role = q_role.List<Domain.Role>();
         if (list_role[0].Name.Equals("reader"))
         {
             LibraryForm lib_form = new LibraryForm(list[0]);
             lib_form.ShowDialog();
         }
         else
         {
             AdminForm admin_form = new AdminForm();
             admin_form.ShowDialog();
         }
     }
     else
     {
         MessageBox.Show("Неверный логин или пароль");
     }
 }
開發者ID:alenkacs,項目名稱:library_system,代碼行數:31,代碼來源:Form1.cs

示例13: TestFixtureSetUp

 public void TestFixtureSetUp()
 {
     _configuration = new Configuration();
     _configuration.Configure();
     _configuration.AddAssembly(typeof(Product).Assembly);
     _sessionFactory = _configuration.BuildSessionFactory();
 }
開發者ID:tasluk,項目名稱:hibernatingrhinos,代碼行數:7,代碼來源:ProductRepository_Fixture.cs

示例14: NHibernateConfiguration

        public static void NHibernateConfiguration(TestContext context)
        {
            log4net.Config.XmlConfigurator.Configure();

            Configuration = new Configuration();
            // lendo o arquivo hibernate.cfg.xml
            Configuration.Configure();

            FilterDefinition filterDef = new FilterDefinition(
                "Empresa","EMPRESA = :EMPRESA",
                new Dictionary<string, IType>() {{"EMPRESA", NHibernateUtil.Int32}}, false);
            Configuration.AddFilterDefinition(filterDef);
            filterDef = new FilterDefinition(
                "Ativa", "ATIVO = 'Y'",
                new Dictionary<string, IType>(), false);
            Configuration.AddFilterDefinition(filterDef);

            // Mapeamento por código
            var mapper = new ModelMapper();
            mapper.AddMappings(Assembly.GetExecutingAssembly().GetExportedTypes());
            HbmMapping mapping = mapper.CompileMappingForAllExplicitlyAddedEntities();
            Configuration.AddMapping(mapping);

            // Gerar o XML a partir do mapeamento de codigo.
            //var mappingXMl = mapping.AsString();

            // Mapeamento por arquivo, in resource.
            Configuration.AddAssembly(Assembly.GetExecutingAssembly());

            // Gerando o SessionFactory
            SessionFactory = Configuration.BuildSessionFactory();
        }
開發者ID:hrickmachado,項目名稱:Crowdlearning-Tecnologia-NHibernate,代碼行數:32,代碼來源:Context.cs

示例15: SqlEntityBulkCopy

        /// <summary>
        /// Wrapper class to produce an Ado.Net Datatable from any entity, 
        /// and perform SqlBulkCopy operations
        /// </summary>
        public SqlEntityBulkCopy(string sqlCnnString, Type entityType)
        {
            if (Cfg == null)
            {
                //Note: The NHibernate.Cfg.Configuration is meant only as an initialization-time object.
                //Note: NHibernate.ISessionFactory is immutable and does not retain any association back to the Session

                Cfg = new Configuration();
                //Cfg.SetProperty("proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle");
                Cfg.SetProperty("dialect", "NHibernate.Dialect.MsSql2008Dialect");
                Cfg.SetProperty("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
                Cfg.SetProperty("connection.driver_class", "NHibernate.Driver.SqlClientDriver");
                Cfg.SetProperty("connection.connection_string", sqlCnnString);

                //add all the mappings embedded in this assembly
                Cfg.AddAssembly(typeof(SqlEntityBulkCopy).Assembly);

                var sessionFactory = Cfg.BuildSessionFactory();
                SessionFactoryImpl = (ISessionFactoryImplementor)sessionFactory;
            }
            EntityType = entityType;
            //_session = SessionFactoryImpl.OpenSession();
            _metaData = SessionFactoryImpl.GetClassMetadata(EntityType);
            _persistentClass = Cfg.GetClassMapping(EntityType);
            _sqlCnn = new SqlConnection(sqlCnnString);
            _sqlBulkCopy = new SqlBulkCopy(_sqlCnn);

            //Debug.WriteLine("EntityName = " + _metaData.EntityName);
            //Debug.WriteLine("IdentifierPropertyName = " + _metaData.IdentifierPropertyName);
            //Debug.WriteLine("IdentifierType = " + _metaData.IdentifierType);

            BuildDataTable();
            BuildAndMapSqlBulkCopy();
        }
開發者ID:dzstoever,項目名稱:ZenFacades,代碼行數:38,代碼來源:SqlEntityBulkCopy.cs


注:本文中的NHibernate.Cfg.Configuration.AddAssembly方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。