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


C# Configuration.AddMapping方法代码示例

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


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

示例1: AddLoquaciousMappings

 static Configuration AddLoquaciousMappings(Configuration nhConfiguration)
 {
     ModelMapper mapper = new ModelMapper();
     mapper.AddMappings(typeof(OrderSagaDataLoquacious).Assembly.GetTypes());
     nhConfiguration.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());
     return nhConfiguration;
 }
开发者ID:odelljl,项目名称:docs.particular.net,代码行数:7,代码来源:Program.cs

示例2: 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

示例3: Main

    static void Main()
    {
        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);

        BusConfiguration busConfiguration = new BusConfiguration();
        busConfiguration.EndpointName("Samples.SqlNHibernate.Receiver");
        busConfiguration.EnableInstallers();

        #region ReceiverConfiguration

        busConfiguration.UseTransport<SqlServerTransport>()
            .DefaultSchema("receiver")
            .UseSpecificConnectionInformation(endpoint =>
            {
                if (endpoint == "error" || endpoint == "audit")
                {
                    return ConnectionInfo.Create().UseSchema("dbo");
                }
                if (endpoint == "Samples.SqlNHibernate.Sender")
                {
                    return ConnectionInfo.Create().UseSchema("sender");
                }
                return null;
            });
        busConfiguration.UsePersistence<NHibernatePersistence>()
            .UseConfiguration(hibernateConfig)
            .RegisterManagedSessionInTheContainer();
        #endregion

        using (Bus.Create(busConfiguration).Start())
        {
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
    }
开发者ID:odelljl,项目名称:docs.particular.net,代码行数:53,代码来源:Program.cs

示例4: OpenSession

        public void OpenSession()
        {
            var config = new Configuration();
            config.SetProperty("connection.driver_class", "NHibernate.Driver.SqlClientDriver");
            config.SetProperty("dialect","NHibernate.Dialect.MsSql2012Dialect");
            config.SetProperty("connection.connection_string", "Data Source=localhost\\SQLEXPRESS;initial catalog=simple-db;Integrated Security=SSPI;");
            config.SetProperty("connection.release_mode","on_close");

            var mapper = new ApplicationMapper();
            config.AddMapping(mapper.Map());

            _factory = config.BuildSessionFactory();
        }
开发者ID:kpaligian,项目名称:simple_app,代码行数:13,代码来源:NHConfig.cs

示例5: Main

    static void Main()
    {
        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

        BusConfiguration busConfiguration = new BusConfiguration();
        busConfiguration.UseTransport<SqlServerTransport>()
            .DefaultSchema("receiver")
            .UseSpecificConnectionInformation(endpoint =>
            {
                if (endpoint == "error")
                {
                    return ConnectionInfo.Create().UseSchema("dbo");
                }
                if (endpoint == "audit")
                {
                    return ConnectionInfo.Create().UseSchema("dbo");
                }
                string schema = endpoint.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries)[0].ToLowerInvariant();
                return ConnectionInfo.Create().UseSchema(schema);
            });
        busConfiguration.UsePersistence<NHibernatePersistence>()
            .UseConfiguration(hibernateConfig)
            .RegisterManagedSessionInTheContainer();
        #endregion

        using (Bus.Create(busConfiguration).Start())
        {
            Console.WriteLine("Press <enter> to exit");
            Console.ReadLine();
        }
    }
开发者ID:ryanrdl,项目名称:docs.particular.net,代码行数:50,代码来源:Program.cs

示例6: FactoryProvider

        static FactoryProvider()
        {
            var modelInspector = new MySimpleModelInspector();
            Assert.IsNotNull(new Entity());
            var mapper = new ModelMapper(modelInspector);
            mapper.AddMappings(Assembly.GetExecutingAssembly().GetExportedTypes());
            mapper.BeforeMapClass += (mi, type, map) =>
                                     map.Id(idmap => idmap.Generator(Generators.HighLow,
                                                                     gmap => gmap.Params(new
                                                                                         	{
                                                                                         		table = "NextHighVaues",
                                                                                         		column = "NextHigh",
                                                                                         		max_lo = 100,
                                                                                         		where = String.Format("EntityName = '{0}'", type.Name.ToLowerInvariant())
                                                                                         	})));
            mapper.BeforeMapClass += (mi, t, map) => map.Table(t.Name.ToLowerInvariant());
            mapper.BeforeMapJoinedSubclass += (mi, t, map) => map.Table(t.Name.ToLowerInvariant());
            mapper.BeforeMapUnionSubclass += (mi, t, map) => map.Table(t.Name.ToLowerInvariant());

            mapper.BeforeMapProperty += (mi, propertyPath, map) =>
                                            {
                                                if (typeof(decimal).Equals(propertyPath.LocalMember.GetPropertyOrFieldType()))
                                                {
                                                    map.Type(NHibernateUtil.Currency);
                                                }
                                            };
            mapper.BeforeMapBag += (mi, propPath, map) =>
                                   	{
                                   		map.Cascade(Cascade.All.Include(Cascade.DeleteOrphans));
                                   		map.BatchSize(10);
                                   	};
            mapper.AddMappings(Assembly.GetExecutingAssembly().GetExportedTypes());
            var domainMapping = mapper.CompileMappingForEachExplicitlyAddedEntity();
            domainMapping.WriteAllXmlMapping();
            var configuration = new Configuration();
            configuration.DataBaseIntegration(c =>
                                              	{
                                              		c.Dialect<MsSql2008Dialect>();
                                              		c.ConnectionString = @"Data Source=localhost\SQLEXPRESS;Initial Catalog=IntroNH;Integrated Security=True;Pooling=False";
                                              		c.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
                                              		c.SchemaAction = SchemaAutoAction.Create;
                                              	});
            foreach(var mapping in domainMapping)
            {
                configuration.AddMapping(mapping);
            }
            configuration.AddAuxiliaryDatabaseObject(CreateHighLowScript(modelInspector, Assembly.GetExecutingAssembly().GetExportedTypes()));

            Factory=configuration.BuildSessionFactory();
        }
开发者ID:Marceli,项目名称:MVCNHibernate,代码行数:50,代码来源:FactoryProvider.cs

示例7: Configure

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

            //configure the connection string
            config.Configure().BuildSessionFactory();

            //add mapping
            var mapper = new ModelMapper();
            mapper.AddMapping<UserMap>();
            mapper.AddMapping<RoleMap>();
            mapper.AddMapping<TagMap>();
            mapper.AddMapping<PostMap>();
            config.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());

            //create session factory
               _sessionFactory = config.BuildSessionFactory();
        }
开发者ID:sazuxerox,项目名称:MyDashboard,代码行数:18,代码来源:Database.cs

示例8: SetupContext

        public void SetupContext()
        {
            var cfg = new Configuration()
                .DataBaseIntegration(x =>
                {
                    x.Dialect<SQLiteDialect>();
                    x.ConnectionString = string.Format(@"Data Source={0};Version=3;New=True;", Path.GetTempFileName());
                });

            var mapper = new ModelMapper();
            mapper.AddMapping<Config.SubscriptionMap>();

            cfg.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());

            new SchemaExport(cfg).Create(false, true);

            subscriptionStorageSessionProvider = new SubscriptionStorageSessionProvider(cfg.BuildSessionFactory());

            storage = new SubscriptionPersister(subscriptionStorageSessionProvider);
        }
开发者ID:james-wu,项目名称:NServiceBus.NHibernate,代码行数:20,代码来源:InMemoryDBFixture.cs

示例9: Creates_configuration_mapping

        public void Creates_configuration_mapping()
        {
            // Arrange
            var sampleMapping = new ResourceMapping<SampleClass>(c => c.Id, "sample_{id}")
            {
                ResourceType = "sampleClasses"
            };

            sampleMapping.AddPropertyGetter("value", c => c.Value);

            var conf = new Configuration();

            // Act
            conf.AddMapping(sampleMapping);

            // Assert
            conf.IsMappingRegistered(typeof(SampleClass)).ShouldBeTrue();
            conf.GetMapping(typeof(SampleClass)).ShouldNotBeNull();
            conf.IsMappingRegistered(typeof(NestedClass)).ShouldBeFalse();
            conf.GetMapping(typeof(NestedClass)).ShouldBeNull();
        }
开发者ID:jacek-gorgon,项目名称:NJsonApi,代码行数:21,代码来源:ConfigurationTest.cs

示例10: CreateContext

        private Context CreateContext()
        {
            var conf = new Configuration();
            var mapping = new ResourceMapping<SampleClass>(c => c.Id, "http://sampleClass/{id}");
            mapping.ResourceType = "sampleClasses";
            mapping.AddPropertyGetter("someValue", c => c.SomeValue);
            mapping.AddPropertyGetter("date", c => c.DateTime);
            conf.AddMapping(mapping);

            return new Context
            {
                Configuration = conf,
                RoutePrefix = string.Empty
            };
        }
开发者ID:jacek-gorgon,项目名称:NJsonApi,代码行数:15,代码来源:TestMetadataWrapper.cs

示例11: NHibernateConfiguration

        private void NHibernateConfiguration()
        {
            var config = new Configuration();
            config.AddAssembly(typeof(MvcApplication).Assembly);
            config.AddAssembly(typeof(MsSqlSpatialDialect).Assembly);
            var modelMapper = new ModelMapper(new ModelInspector());
            modelMapper.AddMappings(typeof(ModelInspector).Assembly.GetExportedTypes());

            var mapping = modelMapper.CompileMappingForAllExplicitlyAddedEntities();
            config.AddMapping(mapping);

            var schema = new SchemaExport(config);
            schema.SetOutputFile("D:\\script.sql");
            schema.Create(true, true);
            //var update = new SchemaUpdate(config);
            //update.Execute(false, true);

            var sessionFactory = config.BuildSessionFactory();
        }
开发者ID:techsavy,项目名称:AtYourService,代码行数:19,代码来源:Global.asax.cs

示例12: CreateContext

        private Context CreateContext()
        {
            var conf = new Configuration();
            var sampleClassMapping = new ResourceMapping<SampleClass>(c => c.Id, "http://sampleClass/{id}");
            sampleClassMapping.ResourceType = "sampleClasses";
            sampleClassMapping.AddPropertyGetter("someValue", c => c.SomeValue);
            sampleClassMapping.AddPropertyGetter("date", c => c.DateTime);

            var nestedClassMapping = new ResourceMapping<NestedClass>(c => c.Id, "http://nestedclass/{id}");
            nestedClassMapping.ResourceType = "nestedClasses";
            nestedClassMapping.AddPropertyGetter("nestedText", c => c.NestedText);

            var deeplyNestedMapping = new ResourceMapping<DeeplyNestedClass>(c => c.Id, "http://deep/{id}");
            deeplyNestedMapping.ResourceType = "deeplyNestedClasses";
            deeplyNestedMapping.AddPropertyGetter("value", c => c.Value);

            var linkMapping = new LinkMapping<SampleClass, NestedClass>()
            {
                IsCollection = true,
                RelationshipName = "nestedValues",
                ResourceMapping = nestedClassMapping,
                ResourceGetter = c => c.NestedClass,
            };

            var deepLinkMapping = new LinkMapping<NestedClass, DeeplyNestedClass>()
            {
                RelationshipName = "deeplyNestedValues",
                ResourceMapping = deeplyNestedMapping,
                ResourceGetter = c => c.DeeplyNestedClass
            };

            sampleClassMapping.Relationships.Add(linkMapping);
            nestedClassMapping.Relationships.Add(deepLinkMapping);

            conf.AddMapping(sampleClassMapping);
            conf.AddMapping(nestedClassMapping);
            conf.AddMapping(deeplyNestedMapping);

            return new Context
            {
                Configuration = conf,
                RoutePrefix = string.Empty
            };
        }
开发者ID:FrontlineEducation,项目名称:Util-JsonApiSerializer,代码行数:44,代码来源:TestSerialization.cs

示例13: CreateContext

        private Context CreateContext()
        {
            var conf = new Configuration();
            var sampleClassMapping = new ResourceMapping<SampleClass>(c => c.Id, "http://sampleClass/{id}");
            sampleClassMapping.ResourceType = "sampleClasses";
            sampleClassMapping.AddPropertyGetter("someValue", c => c.SomeValue);
            sampleClassMapping.AddPropertyGetter("nestedValue", c => c.NestedValue);

            var nestedClassMapping = new ResourceMapping<NestedClass>(c => c.Id, "nested/{id}");
            nestedClassMapping.ResourceType = "nestedClasses";
            nestedClassMapping.AddPropertyGetter("someNestedValue", c => c.SomeNestedValue);

            var linkMapping = new LinkMapping<SampleClass, NestedClass>()
            {
                RelationshipName = "nestedValues",
                ResourceMapping = nestedClassMapping,
                ResourceGetter = c => c.NestedValue,
                ResourceIdGetter = c => c.NestedValueId
            };

            sampleClassMapping.Relationships.Add(linkMapping);

            conf.AddMapping(sampleClassMapping);
            conf.AddMapping(nestedClassMapping);

            return new Context
            {
                Configuration = conf,
                RoutePrefix = appUrl
            };
        }
开发者ID:FrontlineEducation,项目名称:Util-JsonApiSerializer,代码行数:31,代码来源:TestLinks.cs

示例14: ConfigureNHibernate

        private Configuration ConfigureNHibernate()
        {
            var config = new Configuration();

            config.DataBaseIntegration(
                db =>
                    {
                        db.Dialect<SQLiteDialect>();
                        db.Driver<SQLite20Driver>();
                        db.SchemaAction = SchemaAutoAction.Recreate;
                        db.ConnectionString = "Data Source=:memory:;Version=3;New=True;";
                    }).SetProperty(Environment.CurrentSessionContextClass, "thread_static");

            var mapper = new ConventionModelMapper();

            // filter entities
            var baseEntityType = typeof(AbstractEntity);
            mapper.IsEntity(
                (t, declared) => baseEntityType.IsAssignableFrom(t) && baseEntityType != t && !t.IsInterface);
            mapper.IsRootEntity((t, declared) => baseEntityType == t.BaseType);

            // override base properties
            mapper.Class<AbstractEntity>(map => map.Id(x => x.Id, m => m.Generator(Generators.GuidComb)));

            mapper.BeforeMapProperty += (modelinspector, member, propertycustomizer) =>
                                            {
                                                if (member.LocalMember.Name == "Name")
                                                {
                                                    propertycustomizer.Unique(true);
                                                }
                                            };

            // compile
            var mapping =
                mapper.CompileMappingFor(
                    typeof(Person).Assembly.GetExportedTypes().Where(
                        type => typeof(AbstractEntity).IsAssignableFrom(type)));

            // use mappings
            config.AddMapping(mapping);

            return config;
        }
开发者ID:pekkah,项目名称:ItIsAlive,代码行数:43,代码来源:ConfigureBootstrapperExtensionsFacts.cs

示例15: AsyncMain

    static async Task AsyncMain()
    {
        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();
        endpointConfiguration.SendFailedMessagesTo("error");
        endpointConfiguration.AuditProcessedMessagesTo("audit");
        endpointConfiguration.EnableInstallers();
        endpointConfiguration.UseTransport<SqlServerTransport>()
            .DefaultSchema("receiver")
            .UseSpecificSchema(e =>
            {
                switch (e)
                {
                    case "error":
                        return "dbo";
                    case "audit":
                        return "dbo";
                    default:
                        string schema = e.Split(new[]
                        {
                            '.'
                        }, StringSplitOptions.RemoveEmptyEntries)[0].ToLowerInvariant();
                        return schema;
                }
            });

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

        #endregion

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


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