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


C# SubclassMapping类代码示例

本文整理汇总了C#中SubclassMapping的典型用法代码示例。如果您正苦于以下问题:C# SubclassMapping类的具体用法?C# SubclassMapping怎么用?C# SubclassMapping使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: ShouldWriteJoinedSubclassForJoinedSubclassMapping

        public void ShouldWriteJoinedSubclassForJoinedSubclassMapping()
        {
            var mapping = new SubclassMapping(SubclassType.JoinedSubclass);

            writer.VerifyXml(mapping)
                .RootElement.HasName("joined-subclass");
        }
开发者ID:jjchoi,项目名称:fluent-nhibernate,代码行数:7,代码来源:XmlInheritanceWriterTester.cs

示例2: ShouldWriteSubclassForSubclassMapping

        public void ShouldWriteSubclassForSubclassMapping()
        {
            var mapping = new SubclassMapping();

            writer.VerifyXml(mapping)
                .RootElement.HasName("subclass");
        }
开发者ID:sbakshi,项目名称:fluent-nhibernate,代码行数:7,代码来源:XmlInheritanceWriterTester.cs

示例3: MapInheritanceTree

        private void MapInheritanceTree(Type classType, ClassMappingBase mapping, IList<Member> mappedMembers)
        {
            var discriminatorSet = HasDiscriminator(mapping);
            var isDiscriminated = cfg.IsDiscriminated(classType) || discriminatorSet;
            var mappingTypesWithLogicalParents = GetMappingTypesWithLogicalParents();

            foreach (var inheritedClass in mappingTypesWithLogicalParents
                .Where(x => x.Value != null && x.Value.Type == classType)
                .Select(x => x.Key))
            {
                var tempMapping = mapping as ClassMapping;
                var tempIsNull = tempMapping == null;
                if (isDiscriminated && !discriminatorSet && !tempIsNull)
                {
                    var discriminatorColumn = cfg.GetDiscriminatorColumn(classType);
                    var discriminator = new DiscriminatorMapping
                    {
                        ContainingEntityType = classType,
                        Type = new TypeReference(typeof(string))
                    };
                    discriminator.AddDefaultColumn(new ColumnMapping { Name = discriminatorColumn });

                    tempMapping.Discriminator = discriminator;
                    discriminatorSet = true;
                }

                SubclassMapping subclassMapping;

                if(!tempIsNull && tempMapping.IsUnionSubclass)
                {
                    subclassMapping = new SubclassMapping(SubclassType.UnionSubclass)
                    {
                        Type = inheritedClass.Type
                    };
                }
                else if(!isDiscriminated)
                {
                    subclassMapping = new SubclassMapping(SubclassType.JoinedSubclass)
                    {
                        Type = inheritedClass.Type
                    };
                    subclassMapping.Key = new KeyMapping();
                    subclassMapping.Key.AddDefaultColumn(new ColumnMapping { Name = mapping.Type.Name + "_id" });
                }
                else
                    subclassMapping = new SubclassMapping(SubclassType.Subclass)
                    {
                        Type = inheritedClass.Type
                    };

				// track separate set of properties for each sub-tree within inheritance hierarchy
            	var subclassMembers = new List<Member>(mappedMembers);
				MapSubclass(subclassMembers, subclassMapping, inheritedClass);

                mapping.AddSubclass(subclassMapping);

				MergeMap(inheritedClass.Type, subclassMapping, subclassMembers);
            }
        }
开发者ID:henriksen,项目名称:fluent-nhibernate,代码行数:59,代码来源:AutoMapper.cs

示例4: ShouldWriteBag

        public void ShouldWriteBag()
        {
            var mapping = new SubclassMapping();

            mapping.AddCollection(new BagMapping());

            writer.VerifyXml(mapping)
                .Element("bag").Exists();
        }
开发者ID:JasonTrue,项目名称:fluent-nhibernate,代码行数:9,代码来源:XmlSubclassWriterTester.cs

示例5: ProcessSubclass

        public override void ProcessSubclass(SubclassMapping mapping)
        {
            var subclasses = FindClosestSubclasses(mapping.Type);

            foreach (var provider in subclasses)
                mapping.AddSubclass(provider.GetSubclassMapping(new SubclassMapping()));

            base.ProcessSubclass(mapping);
        }
开发者ID:JonKruger,项目名称:fluent-nhibernate,代码行数:9,代码来源:SeparateSubclassVisitor.cs

示例6: ShouldWriteAny

        public void ShouldWriteAny()
        {
            var mapping = new SubclassMapping();

            mapping.AddAny(new AnyMapping());

            writer.VerifyXml(mapping)
                .Element("any").Exists();
        }
开发者ID:JasonTrue,项目名称:fluent-nhibernate,代码行数:9,代码来源:XmlSubclassWriterTester.cs

示例7: ShouldWriteComponents

        public void ShouldWriteComponents()
        {
            var mapping = new SubclassMapping();

            mapping.AddComponent(new ComponentMapping());

            writer.VerifyXml(mapping)
                .Element("component").Exists();
        }
开发者ID:JasonTrue,项目名称:fluent-nhibernate,代码行数:9,代码来源:XmlSubclassWriterTester.cs

示例8: ProcessSubclass

        public override void ProcessSubclass(SubclassMapping mapping)
        {
            var subclasses = subclassProviders
                .Select(x => x.GetSubclassMapping(new SubclassMapping()))
                .Where(x => x.Type.BaseType == mapping.Type);

            foreach (var subclass in subclasses)
                mapping.AddSubclass(subclass);

            base.ProcessSubclass(mapping);
        }
开发者ID:sbakshi,项目名称:fluent-nhibernate,代码行数:11,代码来源:SeparateSubclassVisitor.cs

示例9: Should_write_the_components

        public void Should_write_the_components()
        {
            var classMapping = new SubclassMapping();
            classMapping.AddComponent(new ComponentMapping());

            _mocker.Get<IHbmWriter<ComponentMapping>>()
                .Expect(x => x.Write(classMapping.Components.First())).Return(new HbmComponent());

            _subclassWriter.VerifyXml(classMapping)
                .Element("component").Exists();
        }
开发者ID:paulbatum,项目名称:Fluent-NHibernate-Semantic-Model-Rewrite,代码行数:11,代码来源:HbmSubclassWriterTester.cs

示例10: Should_write_multiple_nestings_of_subclasses

        public void Should_write_multiple_nestings_of_subclasses()
        {
            var subclassMapping = new SubclassMapping();

            subclassMapping.AddSubclass(new SubclassMapping { Name = "Child" });
            subclassMapping.Subclasses.First().AddSubclass(new SubclassMapping { Name = "Grandchild" });

            _subclassWriter.VerifyXml(subclassMapping)
                .Element("subclass").Exists().HasAttribute("name", "Child")
                .Element("subclass").Exists().HasAttribute("name", "Grandchild");
        }
开发者ID:paulbatum,项目名称:Fluent-NHibernate-Semantic-Model-Rewrite,代码行数:11,代码来源:HbmSubclassWriterTester.cs

示例11: Can_map_property

        public void Can_map_property()
        {
            var mapping = new SubclassMapping();
            var subclassPart = new SubclassPart<SalaryEmployee>(mapping);

            subclassPart.Map(x => x.Salary);

            var salaryProperty = mapping.Properties.FirstOrDefault();
            salaryProperty.ShouldNotBeNull();
            salaryProperty.MappedMember.ShouldEqual(ReflectionHelper.GetMember<SalaryEmployee>(x => x.Salary));
        }
开发者ID:paulbatum,项目名称:Fluent-NHibernate-Semantic-Model-Rewrite,代码行数:11,代码来源:SubclassPartTester.cs

示例12: Should_write_the_collections

        public void Should_write_the_collections()
        {
            var subclassMapping = new SubclassMapping();
            subclassMapping.AddCollection(new BagMapping());

            _mocker.Get<IHbmWriter<ICollectionMapping>>()
                .Expect(x => x.Write(subclassMapping.Collections.First())).Return(new HbmBag());

            _subclassWriter.VerifyXml(subclassMapping)
                .Element("bag").Exists();
        }
开发者ID:paulbatum,项目名称:Fluent-NHibernate-Semantic-Model-Rewrite,代码行数:11,代码来源:HbmSubclassWriterTester.cs

示例13: MapInheritanceTree

        private void MapInheritanceTree(Type classType, ClassMappingBase mapping, IList<Member> mappedMembers)
        {
            var discriminatorSet = false;
            var isDiscriminated = cfg.IsDiscriminated(classType);

            foreach (var inheritedClass in mappingTypes.Where(q =>
                q.Type.BaseType == classType &&
                    !cfg.IsConcreteBaseType(q.Type.BaseType)))
            {
                if (isDiscriminated && !discriminatorSet && mapping is ClassMapping)
                {
                    var discriminatorColumn = cfg.GetDiscriminatorColumn(classType);
                    var discriminator = new DiscriminatorMapping
                    {
                        ContainingEntityType = classType,
                        Type = new TypeReference(typeof(string))
                    };
                    discriminator.AddDefaultColumn(new ColumnMapping { Name = discriminatorColumn });

                    ((ClassMapping)mapping).Discriminator = discriminator;
                    discriminatorSet = true;
                }

                SubclassMapping subclassMapping;
                var subclassStrategy = cfg.GetSubclassStrategy(classType);

                if (subclassStrategy == SubclassStrategy.JoinedSubclass)
                {
                    subclassMapping = new SubclassMapping(SubclassType.JoinedSubclass);
                    subclassMapping.Key = new KeyMapping();
                    subclassMapping.Key.AddDefaultColumn(new ColumnMapping { Name = mapping.Type.Name + "_id" });
                }
                else
                    subclassMapping = new SubclassMapping(SubclassType.Subclass);

				// track separate set of properties for each sub-tree within inheritance hierarchy
            	var subclassMembers = new List<Member>(mappedMembers);
				MapSubclass(subclassMembers, subclassMapping, inheritedClass);

                mapping.AddSubclass(subclassMapping);

				MergeMap(inheritedClass.Type, subclassMapping, subclassMembers);
            }
        }
开发者ID:erikojebo,项目名称:fluent-nhibernate,代码行数:44,代码来源:AutoMapper.cs

示例14: ShouldWriteProperties

        public void ShouldWriteProperties()
        {
            var mapping = new SubclassMapping(SubclassType.JoinedSubclass);

            mapping.AddProperty(new PropertyMapping());

            writer.VerifyXml(mapping)
                .Element("property").Exists();
        }
开发者ID:jjchoi,项目名称:fluent-nhibernate,代码行数:9,代码来源:XmlJoinedSubclassWriterTester.cs

示例15: SubclassInspector

 public SubclassInspector(SubclassMapping mapping)
 {
     this.mapping = mapping;
     mappedProperties.Map(x => x.LazyLoad, x => x.Lazy);
 }
开发者ID:nsreddy1986,项目名称:fluent-nhibernate,代码行数:5,代码来源:SubclassInspector.cs


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