• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Edm.AssociationEndMember类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: AddRelProperty

        // <summary>
        // Add the rel property induced by the specified relationship, (if the target
        // end has a multiplicity of one)
        // We only keep track of rel-properties that are "interesting"
        // </summary>
        // <param name="associationType"> the association relationship </param>
        // <param name="fromEnd"> source end of the relationship traversal </param>
        // <param name="toEnd"> target end of the traversal </param>
        private void AddRelProperty(
            AssociationType associationType,
            AssociationEndMember fromEnd, AssociationEndMember toEnd)
        {
            if (toEnd.RelationshipMultiplicity
                == RelationshipMultiplicity.Many)
            {
                return;
            }
            var prop = new RelProperty(associationType, fromEnd, toEnd);
            if (_interestingRelProperties == null
                ||
                !_interestingRelProperties.Contains(prop))
            {
                return;
            }

            var entityType = ((RefType)fromEnd.TypeUsage.EdmType).ElementType;
            List<RelProperty> propList;
            if (!_relPropertyMap.TryGetValue(entityType, out propList))
            {
                propList = new List<RelProperty>();
                _relPropertyMap[entityType] = propList;
            }
            propList.Add(prop);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:34,代码来源:relpropertyhelper.cs


示例2: Can_create_mapping_and_get_association_end

        public void Can_create_mapping_and_get_association_end()
        {
            var associationEnd = new AssociationEndMember("E", new EntityType("E", "N", DataSpace.CSpace));
            var mapping = new EndPropertyMapping(associationEnd);

            Assert.Same(associationEnd, mapping.AssociationEnd);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:7,代码来源:EndPropertyMappingTests.cs


示例3: Can_retrieve_properties

        public void Can_retrieve_properties()
        {
            var source = new EntityType("Source", "N", DataSpace.CSpace);
            var target = new EntityType("Target", "N", DataSpace.CSpace);
            var sourceEnd = new AssociationEndMember("SourceEnd", source);
            var targetEnd = new AssociationEndMember("TargetEnd", target);
            var associationType 
                = AssociationType.Create(
                    "AT",
                    "N",
                    true,
                    DataSpace.CSpace,
                    sourceEnd,
                    targetEnd,
                    null,
                    null);
            var sourceSet = new EntitySet("SourceSet", "S", "T", "Q", source);
            var targetSet = new EntitySet("TargetSet", "S", "T", "Q", target);
            var associationSet
                = AssociationSet.Create(
                    "AS",
                    associationType,
                    sourceSet,
                    targetSet,
                    null);

            var members = new List<EdmMember> { null, targetEnd };
            var memberPath = new ModificationFunctionMemberPath(members, associationSet);

            Assert.Equal(members, memberPath.Members);
            Assert.Equal(targetEnd.Name, memberPath.AssociationSetEnd.Name);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:32,代码来源:MidificationFunctionMemberPathTests.cs


示例4: MatchDependentKeyProperty

        /// <inheritdoc/>
        protected override bool MatchDependentKeyProperty(
            AssociationType associationType,
            AssociationEndMember dependentAssociationEnd,
            EdmProperty dependentProperty,
            EntityType principalEntityType,
            EdmProperty principalKeyProperty)
        {
            Check.NotNull(associationType, "associationType");
            Check.NotNull(dependentAssociationEnd, "dependentAssociationEnd");
            Check.NotNull(dependentProperty, "dependentProperty");
            Check.NotNull(principalEntityType, "principalEntityType");
            Check.NotNull(principalKeyProperty, "principalKeyProperty");

            var otherEnd = associationType.GetOtherEnd(dependentAssociationEnd);

            var navigationProperty
                = dependentAssociationEnd.GetEntityType().NavigationProperties
                                         .SingleOrDefault(n => n.ResultEnd == otherEnd);

            if (navigationProperty == null)
            {
                return false;
            }

            return string.Equals(
                dependentProperty.Name, navigationProperty.Name + principalKeyProperty.Name,
                StringComparison.OrdinalIgnoreCase);
        }
开发者ID:hallco978,项目名称:entityframework,代码行数:29,代码来源:NavigationPropertyNameForeignKeyDiscoveryConvention.cs


示例5: Create_sets_properties_and_seals_the_instance

        public static void Create_sets_properties_and_seals_the_instance()
        {
            var typeUsage = TypeUsage.CreateDefaultTypeUsage(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));
            var associationType = new AssociationType("AssociationType", "Namespace", true, DataSpace.CSpace);
            var source = new EntityType("Source", "Namespace", DataSpace.CSpace);
            var target = new EntityType("Target", "Namespace", DataSpace.CSpace);
            var sourceEnd = new AssociationEndMember("SourceEnd", source);
            var targetEnd = new AssociationEndMember("TargetEnd", target);            

            var navigationProperty =
                NavigationProperty.Create(
                    "NavigationProperty",
                    typeUsage,
                    associationType,
                    sourceEnd,
                    targetEnd,
                    new[]
                        {
                            new MetadataProperty(
                                "TestProperty",
                                TypeUsage.CreateDefaultTypeUsage(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)),
                                "value"),
                        });

            Assert.Equal("NavigationProperty", navigationProperty.Name);
            Assert.Same(typeUsage, navigationProperty.TypeUsage);
            Assert.Same(associationType, navigationProperty.RelationshipType);
            Assert.Same(sourceEnd, navigationProperty.FromEndMember);
            Assert.Same(targetEnd, navigationProperty.ToEndMember);
            Assert.True(navigationProperty.IsReadOnly);

            var metadataProperty = navigationProperty.MetadataProperties.SingleOrDefault(p => p.Name == "TestProperty");
            Assert.NotNull(metadataProperty);
            Assert.Equal("value", metadataProperty.Value);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:35,代码来源:NavigationPropertyTests.cs


示例6: Create_throws_argument_exception_when_called_with_null_or_empty_arguments

        public void Create_throws_argument_exception_when_called_with_null_or_empty_arguments()
        {
            var source = new EntityType("Source", "Namespace", DataSpace.CSpace);
            var target = new EntityType("Target", "Namespace", DataSpace.CSpace);
            var sourceEnd = new AssociationEndMember("SourceEnd", source);
            var targetEnd = new AssociationEndMember("TargetEnd", target);
            var constraint =
                new ReferentialConstraint(
                    sourceEnd,
                    targetEnd,
                    new[] { new EdmProperty("SourceProperty") },
                    new[] { new EdmProperty("TargetProperty") });
            var associationType =
                AssociationType.Create(
                    "AssociationType",
                    "Namespace",
                    true,
                    DataSpace.CSpace,
                    sourceEnd,
                    targetEnd,
                    constraint,
                    Enumerable.Empty<MetadataProperty>());
            var sourceSet = new EntitySet("SourceSet", "Schema", "Table", "Query", source);
            var targetSet = new EntitySet("TargetSet", "Schema", "Table", "Query", target);
            var metadataProperty =
                new MetadataProperty(
                    "MetadataProperty",
                    TypeUsage.CreateDefaultTypeUsage(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)),
                    "value");

            // name is null
            Assert.Throws<ArgumentException>(
                () => AssociationSet.Create(
                    null,
                    associationType,
                    sourceSet,
                    targetSet,
                    new [] { metadataProperty }));

            // name is empty
            Assert.Throws<ArgumentException>(
                () => AssociationSet.Create(
                    String.Empty,
                    associationType,
                    sourceSet,
                    targetSet,
                    new[] { metadataProperty }));

            // type is null
            Assert.Throws<ArgumentNullException>(
                () => AssociationSet.Create(
                    "AssociationSet",
                    null,
                    sourceSet,
                    targetSet,
                    new[] { metadataProperty }));
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:57,代码来源:AssociationSetTests.cs


示例7: IsRequired_should_return_true_when_end_kind_is_required

        public void IsRequired_should_return_true_when_end_kind_is_required()
        {
            var associationEnd = new AssociationEndMember("E", new EntityType("E", "N", DataSpace.CSpace))
                                     {
                                         RelationshipMultiplicity = RelationshipMultiplicity.One
                                     };

            Assert.True(associationEnd.IsRequired());
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:9,代码来源:RelationshipEndMemberExtensionsTests.cs


示例8: Configure

        internal override void Configure(
            AssociationType associationType, AssociationEndMember dependentEnd,
            EntityTypeConfiguration entityTypeConfiguration)
        {
            DebugCheck.NotNull(associationType);
            DebugCheck.NotNull(dependentEnd);
            DebugCheck.NotNull(entityTypeConfiguration);

            associationType.MarkIndependent();
        }
开发者ID:hallco978,项目名称:entityframework,代码行数:10,代码来源:IndependentConstraintConfiguration.cs


示例9: Can_set_and_get_relationship_multiplicity

        public void Can_set_and_get_relationship_multiplicity()
        {
            var relationshipEndMember = new AssociationEndMember("E", new EntityType("E", "N", DataSpace.CSpace));

            Assert.Equal(default(RelationshipMultiplicity), relationshipEndMember.RelationshipMultiplicity);

            relationshipEndMember.RelationshipMultiplicity = RelationshipMultiplicity.Many;

            Assert.Equal(RelationshipMultiplicity.Many, relationshipEndMember.RelationshipMultiplicity);
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:10,代码来源:RelationshipEndMemberTests.cs


示例10: GetOtherEnd

        public static AssociationEndMember GetOtherEnd(
            this AssociationType associationType, AssociationEndMember associationEnd)
        {
            DebugCheck.NotNull(associationType);
            DebugCheck.NotNull(associationEnd);

            return associationEnd == associationType.SourceEnd
                       ? associationType.TargetEnd
                       : associationType.SourceEnd;
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:10,代码来源:AssociationTypeExtensions.cs


示例11: Can_set_and_get_end_member

        public void Can_set_and_get_end_member()
        {
            var endPropertyMapping = new EndPropertyMapping();

            Assert.Null(endPropertyMapping.AssociationEnd);

            var endMember = new AssociationEndMember("E", new EntityType("E", "N", DataSpace.CSpace));
            endPropertyMapping.AssociationEnd = endMember;

            Assert.Same(endMember, endPropertyMapping.AssociationEnd);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:11,代码来源:EndPropertyMappingTests.cs


示例12: GetStorageAssociationSetNameFromManyToMany

 // <summary>
 //     A name derived from a *:* association will be: FK_[Association Name]_[End Name]. Note that we are
 //     getting the association name for *one* of the SSDL associations that are inferred from a CSDL *:*
 //     association. The 'principalEnd' corresponds to the end of the *:* association that will become
 //     the principal end in the 1:* association (where the * end is the newly-constructed entity corresponding
 //     to the link table)
 // </summary>
 internal static string GetStorageAssociationSetNameFromManyToMany(AssociationSet associationSet, AssociationEndMember principalEnd)
 {
     Debug.Assert(associationSet != null, "AssociationSet should not be null");
     Debug.Assert(principalEnd != null, "The principal end cannot be null");
     var associationSetName = String.Empty;
     if (associationSet != null
         && principalEnd != null)
     {
         associationSetName = String.Format(
             CultureInfo.CurrentCulture, Resources.CodeViewManyToManyAssocName, associationSet.Name, principalEnd.Name);
     }
     return associationSetName;
 }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:20,代码来源:OutputGeneratorHelpers.cs


示例13: GetStorageAssociationNameFromManyToMany

 // <summary>
 //     A name derived from a *:* association will be: FK_[Association Name]_[End Name]. Note that we are
 //     getting the association name for *one* of the SSDL associations that are inferred from a CSDL *:*
 //     association. The 'principalEnd' corresponds to the end of the *:* association that will become
 //     the principal end in the 1:* association (where the * end is the newly-constructed entity corresponding
 //     to the link table)
 // </summary>
 internal static string GetStorageAssociationNameFromManyToMany(AssociationEndMember principalEnd)
 {
     var association = principalEnd.DeclaringType as AssociationType;
     Debug.Assert(
         association != null, "The DeclaringType of the AssociationEndMember " + principalEnd.Name + " should be an AssociationType");
     Debug.Assert(principalEnd != null, "The principal end cannot be null");
     var associationName = String.Empty;
     if (association != null
         && principalEnd != null)
     {
         associationName = String.Format(
             CultureInfo.CurrentCulture, Resources.CodeViewManyToManyAssocName, association.Name, principalEnd.Name);
     }
     return associationName;
 }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:22,代码来源:OutputGeneratorHelpers.cs


示例14: WithRelationship

 internal WithRelationship(
     AssociationSet associationSet,
     AssociationEndMember fromEnd,
     EntityType fromEndEntityType,
     AssociationEndMember toEnd,
     EntityType toEndEntityType,
     IEnumerable<MemberPath> toEndEntityKeyMemberPaths)
 {
     m_associationSet = associationSet;
     m_fromEnd = fromEnd;
     m_fromEndEntityType = fromEndEntityType;
     m_toEnd = toEnd;
     m_toEndEntityType = toEndEntityType;
     m_toEndEntitySet = MetadataHelper.GetEntitySetAtEnd(associationSet, toEnd);
     m_toEndEntityKeyMemberPaths = toEndEntityKeyMemberPaths;
 }
开发者ID:junxy,项目名称:entityframework,代码行数:16,代码来源:WithStatement.cs


示例15: AssociationEndMembers_returns_correct_ends_after_modifying_SourceEnd

        public void AssociationEndMembers_returns_correct_ends_after_modifying_SourceEnd()
        {
            var associationType
                = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace)
                {
                    SourceEnd = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace)),
                    TargetEnd = new AssociationEndMember("T", new EntityType("E", "N", DataSpace.CSpace))
                };

            var newSource = new AssociationEndMember("S1", new EntityType("E", "N", DataSpace.CSpace));
            associationType.SourceEnd = newSource;
            associationType.SetReadOnly();

            Assert.Same(associationType.SourceEnd, newSource);
            Assert.Same(associationType.AssociationEndMembers[0], newSource);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:16,代码来源:AssociationTypeTests.cs


示例16: Cannot_add_property_when_read_only

        public void Cannot_add_property_when_read_only()
        {
            var associationEnd = new AssociationEndMember("E", new EntityType("E", "N", DataSpace.CSpace));
            var mapping = new EndPropertyMapping(associationEnd);
            mapping.SetReadOnly();

            Assert.True(mapping.IsReadOnly);

            var scalarPropertyMapping
                = new ScalarPropertyMapping(new EdmProperty("P"), new EdmProperty("C", TypeUsage.Create(new PrimitiveType() { DataSpace = DataSpace.SSpace })));

            Assert.Equal(
                Strings.OperationOnReadOnlyItem,
                Assert.Throws<InvalidOperationException>(
                    () => mapping.AddPropertyMapping(scalarPropertyMapping)).Message);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:16,代码来源:EndPropertyMappingTests.cs


示例17: MatchDependentKeyProperty

        protected override bool MatchDependentKeyProperty(
            AssociationType associationType,
            AssociationEndMember dependentAssociationEnd,
            EdmProperty dependentProperty,
            EntityType principalEntityType,
            EdmProperty principalKeyProperty)
        {
            Check.NotNull(associationType, "associationType");
            Check.NotNull(dependentAssociationEnd, "dependentAssociationEnd");
            Check.NotNull(dependentProperty, "dependentProperty");
            Check.NotNull(principalEntityType, "principalEntityType");
            Check.NotNull(principalKeyProperty, "principalKeyProperty");

            return string.Equals(
                dependentProperty.Name, principalKeyProperty.Name, StringComparison.OrdinalIgnoreCase);
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:16,代码来源:PrimaryKeyNameForeignKeyDiscoveryConvention.cs


示例18: Can_get_and_set_ends_via_wrapper_properties

        public void Can_get_and_set_ends_via_wrapper_properties()
        {
            var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace);

            Assert.Null(associationType.SourceEnd);
            Assert.Null(associationType.TargetEnd);

            var sourceEnd = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace));

            associationType.SourceEnd = sourceEnd;

            var targetEnd = new AssociationEndMember("T", new EntityType("E", "N", DataSpace.CSpace));

            associationType.TargetEnd = targetEnd;

            Assert.Same(sourceEnd, associationType.SourceEnd);
            Assert.Same(targetEnd, associationType.TargetEnd);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:18,代码来源:AssociationTypeTests.cs


示例19: Can_set_and_get_to_role

        public void Can_set_and_get_to_role()
        {
            var toRole = new AssociationEndMember("D", new EntityType("E", "N", DataSpace.CSpace));

            var referentialConstraint
                = new ReferentialConstraint(
                    new AssociationEndMember("P", new EntityType("E", "N", DataSpace.CSpace)),
                    toRole,
                    new[] { EdmProperty.Primitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32)) },
                    new[] { EdmProperty.Primitive("D", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32)) });

            Assert.Same(toRole, referentialConstraint.ToRole);

            var toRole2 = new AssociationEndMember("D2", new EntityType("E", "N", DataSpace.CSpace));

            referentialConstraint.ToRole = toRole2;

            Assert.Same(toRole2, referentialConstraint.ToRole);
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:19,代码来源:ReferentialConstraintTests.cs


示例20: Can_set_and_get_dependent_end

        public void Can_set_and_get_dependent_end()
        {
            var dependentEnd1 = new AssociationEndMember("D", new EntityType());

            var referentialConstraint
                = new ReferentialConstraint(
                    new AssociationEndMember("P", new EntityType()),
                    dependentEnd1,
                    new[] { EdmProperty.Primitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32)) },
                    new[] { EdmProperty.Primitive("D", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32)) });

            Assert.Same(dependentEnd1, referentialConstraint.DependentEnd);

            var dependentEnd2 = new AssociationEndMember("D2", new EntityType());

            referentialConstraint.DependentEnd = dependentEnd2;

            Assert.Same(dependentEnd2, referentialConstraint.DependentEnd);
        }
开发者ID:jwanagel,项目名称:jjwtest,代码行数:19,代码来源:ReferentialConstraintTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Edm.AssociationSet类代码示例发布时间:2022-05-26
下一篇:
C# EntityClient.EntityConnection类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap