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


C# ClassMap.HasManyToMany方法代码示例

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


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

示例1: ShouldAllowConventionsToAlterBiDirectionalTableNames

        public void ShouldAllowConventionsToAlterBiDirectionalTableNames()
        {
            var model = new PersistenceModel();
            var leftMap = new ClassMap<Left>();

            leftMap.Id(x => x.Id);
            leftMap.HasManyToMany(x => x.Rights);

            var rightMap = new ClassMap<Right>();

            rightMap.Id(x => x.Id);
            rightMap.HasManyToMany(x => x.Lefts);

            model.Add(leftMap);
            model.Add(rightMap);
            model.Conventions.Add<TestTableNameConvention>();

            var mappings = model.BuildMappings();

            var leftMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Left)).First();
            var rightMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Right)).First();

            leftMapping.Collections.First().TableName.ShouldEqual("Lefts_Rights");
            rightMapping.Collections.First().TableName.ShouldEqual("Lefts_Rights");
        }
开发者ID:heyitsanewb,项目名称:PokeWorld-Online,代码行数:25,代码来源:ManyToManyTableNameTests.cs

示例2: ShouldHaveSameTableNameForBothSidesOfMappingWhenRightSpecified

        public void ShouldHaveSameTableNameForBothSidesOfMappingWhenRightSpecified()
        {
            var model = new PersistenceModel();
            var leftMap = new ClassMap<Left>();

            leftMap.Id(x => x.Id);
            leftMap.HasManyToMany(x => x.Rights);

            var rightMap = new ClassMap<Right>();

            rightMap.Id(x => x.Id);
            rightMap.HasManyToMany(x => x.Lefts)
                .Table("MyJoinTable");

            model.Add(leftMap);
            model.Add(rightMap);

            var mappings = model.BuildMappings();

            var leftMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Left)).First();
            var rightMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Right)).First();

            leftMapping.Collections.First().TableName.ShouldEqual("MyJoinTable");
            rightMapping.Collections.First().TableName.ShouldEqual("MyJoinTable");
        }
开发者ID:nsreddy1986,项目名称:fluent-nhibernate,代码行数:25,代码来源:ManyToManyTableNameTests.cs

示例3: ShouldSetForeignKeyOnManyToMany

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

            classMap.HasManyToMany(x => x.Children);

            model.Add(classMap);

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

示例4: VerifyModel

        private void VerifyModel(Action<ICollectionMapping> modelVerification)
        {
            var classMap = new ClassMap<ExampleInheritedClass>();
            classMap.Id(x => x.Id);
            var map = classMap.HasManyToMany(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:erikojebo,项目名称:fluent-nhibernate,代码行数:16,代码来源:HasManyToManyConventionTests.cs

示例5: ShouldHaveSameTableNameForBothSidesOfMappingWhenHasMultipleBiDirectionalManyToManysOnSameEntities

        public void ShouldHaveSameTableNameForBothSidesOfMappingWhenHasMultipleBiDirectionalManyToManysOnSameEntities()
        {
            var model = new PersistenceModel();
            var leftMap = new ClassMap<Left>();

            leftMap.Id(x => x.Id);
            leftMap.HasManyToMany(x => x.Rights);
            leftMap.HasManyToMany(x => x.SecondRights);

            var rightMap = new ClassMap<Right>();

            rightMap.Id(x => x.Id);
            rightMap.HasManyToMany(x => x.Lefts);
            rightMap.HasManyToMany(x => x.SecondLefts);

            model.Add(leftMap);
            model.Add(rightMap);

            var mappings = model.BuildMappings();

            var leftMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Left)).First();
            var rightMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Right)).First();

            leftMapping.Collections.First().TableName.ShouldEqual("LeftsToRights");
            rightMapping.Collections.First().TableName.ShouldEqual("LeftsToRights");

            leftMapping.Collections.ElementAt(1).TableName.ShouldEqual("SecondLeftsToSecondRights");
            rightMapping.Collections.ElementAt(1).TableName.ShouldEqual("SecondLeftsToSecondRights");
        }
开发者ID:heyitsanewb,项目名称:PokeWorld-Online,代码行数:29,代码来源:ManyToManyTableNameTests.cs

示例6: ShouldHaveSameTableNameForUniDirectionalMapping

        public void ShouldHaveSameTableNameForUniDirectionalMapping()
        {
            var model = new PersistenceModel();
            var leftMap = new ClassMap<Left>();

            leftMap.Id(x => x.Id);
            leftMap.HasManyToMany(x => x.Rights);

            var rightMap = new ClassMap<Right>();

            rightMap.Id(x => x.Id);

            model.Add(leftMap);
            model.Add(rightMap);

            var mappings = model.BuildMappings();

            var leftMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Left)).First();

            leftMapping.Collections.First().TableName.ShouldEqual("RightToLeft");
        }
开发者ID:heyitsanewb,项目名称:PokeWorld-Online,代码行数:21,代码来源:ManyToManyTableNameTests.cs

示例7: ShouldApplyToHasManyToMany

        public void ShouldApplyToHasManyToMany()
        {
            var conventions = new[]
            {
                MockRepository.GenerateMock<IMappingPartConvention>()
            };
            var cm = new ClassMap<ManyToManyTarget>();
            var manyToMany = cm.HasManyToMany(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(manyToMany));
        }
开发者ID:HudsonAkridge,项目名称:fluent-nhibernate,代码行数:20,代码来源:ClassMappingPartDiscoveryConventionTester.cs


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