当前位置: 首页>>代码示例>>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;未经允许,请勿转载。