当前位置: 首页>>代码示例>>C#>>正文


C# ModelMapper.AddMapping方法代码示例

本文整理汇总了C#中ModelMapper.AddMapping方法的典型用法代码示例。如果您正苦于以下问题:C# ModelMapper.AddMapping方法的具体用法?C# ModelMapper.AddMapping怎么用?C# ModelMapper.AddMapping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ModelMapper的用法示例。


在下文中一共展示了ModelMapper.AddMapping方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Initialize

        public static void Initialize(TestContext context)
        {
            var cfg = new Configuration();
            cfg.DataBaseIntegration(x => {
                x.ConnectionString = "Server=localhost;Database=test;Uid=root;Pwd=kmn23po;";
                x.Driver<MySqlDataDriver>();
                x.Dialect<MySQLDialect>();
                x.LogSqlInConsole = true;
                x.BatchSize = 30;
            });

            var mapper = new ModelMapper();
            mapper.AddMapping<ParentMap>();
            mapper.AddMapping<ParentWithGuidMap>();
            mapper.AddMapping<ChildMap>();

            cfg.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());

            sessionFactory = cfg.BuildSessionFactory();

            var schemaUpdate = new SchemaUpdate(cfg);
            schemaUpdate.Execute(false, true);

            InsertData();
        }
开发者ID:jplindgren,项目名称:NHibernateCodeCheat,代码行数:25,代码来源:UnitTest1.cs

示例2: GetMappings

		protected override HbmMapping GetMappings()
		{
			var mapper = new ModelMapper();
			mapper.AddMapping<PersonMapper>();
			mapper.AddMapping<CachedPersonMapper>();

			return mapper.CompileMappingForAllExplicitlyAddedEntities();
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:8,代码来源:FixtureByCode.cs

示例3: CompiledMappings_ShouldNotDependOnAddedOrdering_AddedBy_AddMapping

 public void CompiledMappings_ShouldNotDependOnAddedOrdering_AddedBy_AddMapping()
 {
     var mapper = new ModelMapper();
     mapper.AddMapping<EntityMapping>();
     mapper.AddMapping<DerivedClassMapping>();
     mapper.AddMapping<BaseClassMapping>();
     var config = TestConfigurationHelper.GetDefaultConfiguration();
     Assert.DoesNotThrow(() => config.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities()));
 }
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:9,代码来源:Fixture.cs

示例4: GetMappings

        private static HbmMapping GetMappings()
        {
            var mapper = new ModelMapper();

            mapper.AddMapping<BlogPostMapping>();
            mapper.AddMapping<CommentMapping>();

            HbmMapping mapping = mapper.CompileMappingFor(new[] { typeof(BlogPost), typeof(Comment) });

            return mapping;
        }
开发者ID:drypa,项目名称:BlogSample_v2,代码行数:11,代码来源:NHibernateConfigurator.cs

示例5: CreateMapper

		private IEnumerable<HbmMapping> CreateMapper()
		{
			var mapper = new ModelMapper();

			mapper.AddMapping<XmlAsStringEntityMap>();
			mapper.AddMapping<XmlEntityMap>();
			mapper.AddMapping<BinaryEntityMap>();
			mapper.AddMapping<ProtobufEntityMap>();
			mapper.AddMapping<JsonEntityMap>();
			return mapper.CompileMappingForEachExplicitlyAddedEntity();
		}
开发者ID:khaale,项目名称:Khaale.Research.MSSQLSerializationDemo,代码行数:11,代码来源:DbSetup.cs

示例6: ExportSchema

        public void ExportSchema()
        {
            // Inicio do Setup do NH
            var config = new Configuration();

            config.DataBaseIntegration(
                db =>
                {
                    db.Dialect<MsSql2008Dialect>();
                    db.ConnectionStringName = "DefaultNH";
                    db.SchemaAction = SchemaAutoAction.Recreate;
                });

            ModelMapper modelMapper = new ModelMapper();

            modelMapper.AddMapping<ProdutoNHMap>();
            modelMapper.AddMapping<DepartamentoNHMap>();

            config.AddDeserializedMapping(modelMapper.CompileMappingForAllExplicitlyAddedEntities(), "Domain");

            ISessionFactory sessionFactory = config.BuildSessionFactory();

            // Fim do Setup do NH - Isso deve ficar no start da app (Global.asax por exemplo)

            using (var session = sessionFactory.OpenSession())
            {
                // Criteria API
                // HQL
                // Linq

                var produtosAcima1000 = session.QueryOver<Produto>().List();

                foreach (var produto in produtosAcima1000)
                {
                    Console.WriteLine(produto);
                }
            }

            using (var session = sessionFactory.OpenSession())
            {
                var produto = new Produto();

                produto.Nome = "Teste #1";
                produto.Preco = 90;
                produto.Quantidade = 123;
                produto.Ativo = true;

                session.Save(produto);
                session.Flush();
            }
        }
开发者ID:TiagoSoczek,项目名称:MOC,代码行数:51,代码来源:NHibernateTestCase.cs

示例7: CreateSessionFactory

 public static ISessionFactory CreateSessionFactory()
 {
     var configuration = new Configuration();
     configuration.Configure();
     var mapper = new ModelMapper();
     mapper.AddMapping<FileMapping>();
     mapper.AddMapping<CinemaMapping>();
     mapper.AddMapping<LanguageMapping>();
     mapper.AddMapping<CompanyMapping>();
     configuration.AddDeserializedMapping(mapper.CompileMappingForAllExplicitlyAddedEntities(), null);
     var factory = configuration.BuildSessionFactory();
     new SchemaUpdate(configuration).Execute(false, true);
     return factory;
 }
开发者ID:LeagueOfDevelopers,项目名称:Movie-Extended,代码行数:14,代码来源:SessionFactoryConfig.cs

示例8: CreateSessionFactory

        /// <summary>
        /// Creates session factory
        /// </summary>
        /// <param name="configurationReader">configuration reader</param>
        /// <returns></returns>
        private static ISessionFactory CreateSessionFactory(IConfigurationReader configurationReader)
        {
            var configuration = new NHibernate.Cfg.Configuration();
            configuration.SessionFactoryName("Jumblocks Blog");

            configuration.DataBaseIntegration(db =>
            {
                db.Dialect<MsSql2008FixedDialect>();
                db.IsolationLevel = IsolationLevel.ReadCommitted;
                db.ConnectionString = configurationReader.ConnectionStrings["BlogDb"].ConnectionString;
                db.BatchSize = 100;

                //for testing
                db.LogFormattedSql = true;
                db.LogSqlInConsole = true;
                db.AutoCommentSql = true;
            });

            var mapper = new ModelMapper();
            mapper.AddMapping<BlogPostMap>();
            mapper.AddMapping<BlogUserMap>();
            mapper.AddMapping<ImageReferenceMap>();
            mapper.AddMapping<TagMap>();
            mapper.AddMapping<SeriesMap>();

            mapper.AddMapping<UserMap>();
            mapper.AddMapping<RoleMap>();
            mapper.AddMapping<OperationMap>();

            configuration.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());
            configuration.CurrentSessionContext<WebSessionContext>();

            return configuration.BuildSessionFactory();
        }
开发者ID:AndyCC,项目名称:Jumbleblocks-website,代码行数:39,代码来源:DatabaseSetup.cs

示例9: Configure

        public static void Configure()
        {
            var config = new Configuration().Configure();

            var mapper = new ModelMapper();
            mapper.AddMapping<UserMap>();
            mapper.AddMapping<RoleMap>();
            mapper.AddMapping<PostMap>();
            mapper.AddMapping<TagMap>();

            config.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());

            _sessionFactory = config.BuildSessionFactory();
        }
开发者ID:wingertge,项目名称:SimpleBlog,代码行数:14,代码来源:Database.cs

示例10: ApplyMappings

        void ApplyMappings(Configuration config)
        {
            var mapper = new ModelMapper();
            mapper.AddMapping<OutboxEntityMap>();

            config.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());
        }
开发者ID:james-wu,项目名称:NServiceBus.NHibernate,代码行数:7,代码来源:NHibernateOutboxStorage.cs

示例11: LoadMappingFrom

        public static HbmMapping LoadMappingFrom(params Assembly[] assemblies)
        {
            Require.NotNull(assemblies, "assemblies");

            var baseTypes = new Type[] {
                typeof(ClassMapping<>),
                typeof(JoinedSubclassMapping<>),
                typeof(UnionSubclassMapping<>),
                typeof(SubclassMapping<>)
            };

            var mapper = new ModelMapper();

            foreach (var asm in assemblies)
            {
                foreach (var type in asm.GetTypes())
                {
                    if (!type.IsClass || type.IsAbstract || type.IsInterface || !type.BaseType.IsGenericType) continue;

                    if (!baseTypes.Contains(type.BaseType.GetGenericTypeDefinition())) continue;

                    mapper.AddMapping(type);
                }
            }

            var mapping = mapper.CompileMappingForAllExplicitlyAddedEntities();
            mapping.autoimport = false;

            return mapping;
        }
开发者ID:sigcms,项目名称:Seeger,代码行数:30,代码来源:ByCodeMappingLoader.cs

示例12: Setup

        public void Setup()
        {
            var mapper = new ModelMapper();
            mapper.AddMapping<OutboxEntityMap>();

            var configuration = new global::NHibernate.Cfg.Configuration()
                .AddProperties(new Dictionary<string, string>
                {
                    { "dialect", dialect },
                    { global::NHibernate.Cfg.Environment.ConnectionString,connectionString }
                });

            configuration.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());

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

            SessionFactory = configuration.BuildSessionFactory();

            Session = SessionFactory.OpenSession();

            persister = new OutboxPersister
            {
                StorageSessionProvider = new FakeSessionProvider(SessionFactory, Session),
                EndpointName = "TestEndpoint"
            };

        }
开发者ID:andrewq,项目名称:NServiceBus.NHibernate,代码行数:27,代码来源:InMemoryDBFixture.cs

示例13: AsyncMain

    static async Task AsyncMain()
    {
        Console.Title = "Samples.SqlNHibernate.Receiver";
        Configuration hibernateConfig = new Configuration();
        hibernateConfig.DataBaseIntegration(x =>
        {
            x.ConnectionStringName = "NServiceBus/Persistence";
            x.Dialect<MsSql2012Dialect>();
        });

        #region NHibernate

        hibernateConfig.SetProperty("default_schema", "receiver");

        #endregion

        ModelMapper mapper = new ModelMapper();
        mapper.AddMapping<OrderMap>();
        hibernateConfig.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());

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

        #region ReceiverConfiguration

        EndpointConfiguration endpointConfiguration = new EndpointConfiguration("Samples.SqlNHibernate.Receiver");
        endpointConfiguration.SendFailedMessagesTo("error");
        endpointConfiguration.AuditProcessedMessagesTo("audit");
        endpointConfiguration.EnableInstallers();
        endpointConfiguration.UseTransport<SqlServerTransport>()
            .DefaultSchema("receiver")
            .UseSpecificSchema(e =>
            {
                if (e == "error" || e == "audit")
                {
                    return "dbo";
                }
                if (e == "Samples.SqlNHibernate.Sender")
                {
                    return "sender";
                }
                return null;
            });

        endpointConfiguration.UsePersistence<NHibernatePersistence>()
            .UseConfiguration(hibernateConfig);

        #endregion

        IEndpointInstance endpoint = await Endpoint.Start(endpointConfiguration);
        try
        {
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
        finally
        {
            await endpoint.Stop();
        }
    }
开发者ID:odelljl,项目名称:docs.particular.net,代码行数:59,代码来源:Program.cs

示例14: GetMappings

        protected static HbmMapping GetMappings()
        {
            //There is a dynamic way to do this, but for simplicity I chose to hard code
            var mapper = new ModelMapper();

            mapper.AddMapping<UsersMap>();
            var mapping = mapper.CompileMappingFor(new[] { typeof(Users) });
            return mapping;
        }
开发者ID:cyber48,项目名称:Astra,代码行数:9,代码来源:MainWindow.xaml.cs

示例15: NHMigrationDemoConfig

        public NHMigrationDemoConfig()
        {
            this.DataBaseIntegration(db =>
            {
                db.ConnectionString = "Data Source=(local);initial catalog=NHMigrationDemo;Integrated Security=SSPI";
                db.Dialect<MsSql2012Dialect>();
                db.BatchSize = 150;
                db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
                db.LogFormattedSql = true;
            });
            var mapper = new ModelMapper();
            mapper.AddMapping(new CatMapping());
            mapper.AddMapping(new DogMapping());
            this.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());

            this.UseTableBasedMigrations("NHMigrationDemoConfig");
            this.RegisterAllMigrationsFrom(GetType().Assembly);
        }
开发者ID:jrgcubano,项目名称:NHMigrationDemo,代码行数:18,代码来源:NHMigrationDemoConfig.cs


注:本文中的ModelMapper.AddMapping方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。