當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。