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


C# ConventionModelMapper.AddMapping方法代码示例

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


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

示例1: GetIdentityMappings

        /// <summary>
        /// Gets a mapping that can be used with NHibernate.
        /// </summary>
        /// <param name="additionalTypes">Additional Types that are to be added to the mapping, this is useful for adding your ApplicationUser class</param>
        /// <returns></returns>
        public static HbmMapping GetIdentityMappings(System.Type[] additionalTypes)
        {
            var baseEntityToIgnore = new[]
            {
                typeof(EntityWithTypedId<int>),
                typeof(EntityWithTypedId<string>)
            };

            // Modified for NS: PIMS.Infrastructure.NHibernate.NHAspNetIdentity
            var allEntities = new List<System.Type> {
                typeof(IdentityUser),
                typeof(IdentityRole),
                typeof(IdentityUserLogin),
                typeof(IdentityUserClaim),
            };
            allEntities.AddRange(additionalTypes);

            var mapper = new ConventionModelMapper();
            DefineBaseClass(mapper, baseEntityToIgnore.ToArray());
            mapper.IsComponent((type, declared) => typeof(ValueObject).IsAssignableFrom(type));

               // Modified for NS: PIMS.Infrastructure.NHibernate.NHAspNetIdentity
            mapper.AddMapping<IdentityUserMap>();
            mapper.AddMapping<IdentityRoleMap>();
            mapper.AddMapping<IdentityUserClaimMap>();

            return mapper.CompileMappingFor(allEntities);
        }
开发者ID:RichardPAsch,项目名称:PIMS,代码行数:33,代码来源:MappingHelper.cs

示例2: Configure

        public static void Configure(ISessionStorage storage)
        {
            var baseEntityToIgnore = new[] { 
                typeof(NHibernate.AspNet.Identity.DomainModel.EntityWithTypedId<int>), 
                typeof(NHibernate.AspNet.Identity.DomainModel.EntityWithTypedId<string>), 
            };

            var allEntities = new[] { 
                typeof(IdentityUser), 
                typeof(ApplicationUser), 
                typeof(IdentityRole), 
                typeof(IdentityUserLogin), 
                typeof(IdentityUserClaim), 
            };

            var mapper = new ConventionModelMapper();
            DefineBaseClass(mapper, baseEntityToIgnore);
            mapper.IsComponent((type, declared) => typeof(NHibernate.AspNet.Identity.DomainModel.ValueObject).IsAssignableFrom(type));

            mapper.AddMapping<IdentityUserMap>();
            mapper.AddMapping<IdentityRoleMap>();
            mapper.AddMapping<IdentityUserClaimMap>();

            var mapping = mapper.CompileMappingFor(allEntities);
            System.Diagnostics.Debug.WriteLine(mapping.AsString());

            var configuration = NHibernateSession.Init(storage, mapping);
            BuildSchema(configuration);
        }
开发者ID:robocik,项目名称:NHibernate.AspNet.Identity,代码行数:29,代码来源:DataConfig.cs

示例3: GetIdentityMappings

        /// <summary>
        /// Gets a mapping that can be used with NHibernate.
        /// </summary>
        /// <param name="additionalTypes">Additional Types that are to be added to the mapping, this is useful for adding your ApplicationUser class</param>
        /// <returns></returns>
        public static HbmMapping GetIdentityMappings(System.Type[] additionalTypes)
        {
            var baseEntityToIgnore = new[] { 
                typeof(NHibernate.AspNet.Identity.DomainModel.EntityWithTypedId<int>), 
                typeof(NHibernate.AspNet.Identity.DomainModel.EntityWithTypedId<string>), 
            };

            var allEntities = new List<System.Type> { 
                typeof(ApplicationTenant),
                typeof(IdentityUser),                 
                typeof(IdentityRole), 
                typeof(IdentityUserLogin), 
                typeof(IdentityUserClaim),
            };
            allEntities.AddRange(additionalTypes);

            var mapper = new ConventionModelMapper();
            DefineBaseClass(mapper, baseEntityToIgnore.ToArray());
            mapper.IsComponent((type, declared) => typeof(NHibernate.AspNet.Identity.DomainModel.ValueObject).IsAssignableFrom(type));

            mapper.AddMapping<IdentityUserMap>();
            mapper.AddMapping<IdentityRoleMap>();
            mapper.AddMapping<IdentityUserClaimMap>();
            mapper.AddMapping<ApplicationTenantMap>();

            return mapper.CompileMappingFor(allEntities);
        }
开发者ID:dags20,项目名称:NHibernate.AspNet.Identity.MultiTenant,代码行数:32,代码来源:MappingHelper.cs

示例4: SessionFactoryProvider

        /// <summary>
        /// constructor configures a SessionFactory based on the configuration passed in
        /// </summary>
        private SessionFactoryProvider()
        {
            Name = "NHibernate.AspNet.Identity";

            var baseEntityToIgnore = new[] { 
                typeof(SharpArch.Domain.DomainModel.Entity), 
                typeof(EntityWithTypedId<int>), 
                typeof(EntityWithTypedId<string>), 
            };

            var allEntities = new[] {                 
                typeof(IdentityUser), 
                typeof(ApplicationUser), 
                typeof(IdentityRole), 
                typeof(IdentityUserLogin), 
                typeof(IdentityUserClaim),                 
                typeof(Foo),                 
                typeof(ApplicationTenant),
            };

            var mapper = new ConventionModelMapper();
            DefineBaseClass(mapper, baseEntityToIgnore);
            mapper.IsComponent((type, declared) => typeof(ValueObject).IsAssignableFrom(type));

            mapper.AddMapping<ApplicationTenantMap>();
            mapper.AddMapping<IdentityUserMap>();
            mapper.AddMapping<IdentityRoleMap>();
            mapper.AddMapping<IdentityUserClaimMap>();

            var mapping = mapper.CompileMappingForEach(allEntities);

            _configuration = new Configuration();
            _configuration.Configure("sqlite-nhibernate-config.xml");
            foreach (var map in mapping)
            {
                Console.WriteLine(map.AsString());
                _configuration.AddDeserializedMapping(map, null);
            }


            //log4net.Config.XmlConfigurator.Configure();
            SessionFactory = _configuration.BuildSessionFactory();
        }
开发者ID:dags20,项目名称:NHibernate.AspNet.Identity.MultiTenant,代码行数:46,代码来源:SessionFactoryProvider.cs

示例5: BuildSessionFactory

 static Configuration BuildSessionFactory() {
     var config = new Configuration();
     config.SetProperties(CreateSessionFactoryDefaultProperties());
     config.SetProperty(NhCfgEnv.ConnectionString, "Data Source=db-dev4.gdepb.gov.cn;Initial Catalog=Test;Persist Security Info=True;User ID=udev;Password=devdev");
     var mapper = new ConventionModelMapper();
     mapper.AddMapping(new UserMapping());
     mapper.AddMapping(new RoleMapping());
     var mapping = mapper.CompileMappingForAllExplicitlyAddedEntities();
     config.AddMapping(mapping);
     return config;
 }
开发者ID:beginor,项目名称:practice,代码行数:11,代码来源:UnitTest.cs


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