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


C# ClassMap.HasMany方法代码示例

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


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

示例1: CanMapCollection

        public void CanMapCollection()
        {
            var classMap = new ClassMap<Artist>();
            classMap.HasMany<Album>(x => x.Albums);
            ClassMapping mapping = classMap.GetClassMapping();

            var collection = mapping.Collections.FirstOrDefault() as BagMapping;
            collection.ShouldNotBeNull();
            collection.MappedMember.ShouldEqual(ReflectionHelper.GetMember<Artist>(x => x.Albums));
        }
开发者ID:paulbatum,项目名称:Fluent-NHibernate-Semantic-Model-Rewrite,代码行数:10,代码来源:ClassMapTester.cs

示例2: ShouldSetForeignKeyOnOneToMany

        public void ShouldSetForeignKeyOnOneToMany()
        {
            var classMap = new ClassMap<ExampleInheritedClass>();

            classMap.Id(x => x.Id);
            classMap.HasMany(x => x.Children);

            model.Add(classMap);

            model.BuildMappings()
                .First()
                .Classes.First()
                .Collections.First()
                .Key.Columns.First().Name.ShouldEqual("ExampleInheritedClass!");
        }
开发者ID:garrisonx,项目名称:NH3BegginnersGuide,代码行数:15,代码来源:ForeignKeyConventionTests.cs

示例3: VerifyModel

        private void VerifyModel(Action<ICollectionMapping> modelVerification)
        {
            var classMap = new ClassMap<ExampleInheritedClass>();
            var map = classMap.HasMany(x => x.Children);

            model.Add(classMap);

            var generatedModels = model.BuildMappings();
            var modelInstance = generatedModels
                .First(x => x.Classes.FirstOrDefault(c => c.Type == typeof(ExampleInheritedClass)) != null)
                .Classes.First()
                .Collections.First();

            modelVerification(modelInstance);
        }
开发者ID:JonKruger,项目名称:fluent-nhibernate,代码行数:15,代码来源:HasManyConventionTests.cs

示例4: Where

        private string Where(string where)
        {
            var classMap = new ClassMap<Target>();
            classMap.Id(x => x.Id);
            classMap.HasMany(x => x.Children)
                .Where(where);

            var model = new PersistenceModel();

            model.Add(classMap);

            return model.BuildMappings()
                .First()
                .Classes.First()
                .Collections.First()
                .Where;
        }
开发者ID:roelofb,项目名称:fluent-nhibernate,代码行数:17,代码来源:WhereTests.cs

示例5: Mapping

        private void Mapping(Action<OneToManyPart<ExampleClass>> mappingDefinition)
        {
            var classMap = new ClassMap<ExampleParentClass>();
            classMap.Id(x => x.Id);
            var map = classMap.HasMany(x => x.Examples)
                .AsArray(x => x.Id);

            mappingDefinition(map);

            mapping = classMap;
            mappingType = typeof(ExampleParentClass);
        }
开发者ID:AndyStewart,项目名称:fluent-nhibernate,代码行数:12,代码来源:ArrayConventionTests.cs

示例6: VerifyModel

        private void VerifyModel(Action<ArrayMapping> modelVerification)
        {
            var classMap = new ClassMap<ExampleParentClass>();
            classMap.Id(x => x.Id);
            var map = classMap.HasMany(x => x.Examples)
                .AsArray(x => x.Id);

            model.Add(classMap);

            var generatedModels = model.BuildMappings();
            var modelInstance = generatedModels
                .First(x => x.Classes.FirstOrDefault(c => c.Type == typeof(ExampleParentClass)) != null)
                .Classes.First()
                .Collections.First();

            modelVerification((ArrayMapping)modelInstance);
        }
开发者ID:roelofb,项目名称:fluent-nhibernate,代码行数:17,代码来源:ArrayConventionTests.cs

示例7: ShouldApplyToHasMany

        public void ShouldApplyToHasMany()
        {
            var conventions = new[]
            {
                MockRepository.GenerateMock<IMappingPartConvention>()
            };
            var cm = new ClassMap<OneToManyTarget>();
            var oneToMany = cm.HasMany(x => x.BagOfChildren);

            conventionFinder.Stub(x => x.Find<IMappingPartConvention>())
                .Return(conventions);

            conventions[0].Stub(x => x.Accept(null))
                .IgnoreArguments()
                .Return(true);

            convention.Apply(cm);

            conventions[0].AssertWasCalled(x => x.Apply(oneToMany));
        }
开发者ID:HudsonAkridge,项目名称:fluent-nhibernate,代码行数:20,代码来源:ClassMappingPartDiscoveryConventionTester.cs


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