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

C# Edm.AssociationSet类代码示例

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

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



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

示例1: 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)
                      {
                          SourceEnd = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace)),
                          TargetEnd = new AssociationEndMember("T", new EntityType("E", "N", DataSpace.CSpace))
                      };

            var associationSet = new AssociationSet("A", associationType);

            Assert.Null(associationSet.SourceSet);
            Assert.Null(associationSet.TargetSet);

            var sourceEntitySet = new EntitySet();

            associationSet.SourceSet = sourceEntitySet;

            var targetEntitySet = new EntitySet();

            associationSet.TargetSet = targetEntitySet;

            Assert.Same(sourceEntitySet, associationSet.SourceSet);
            Assert.Same(targetEntitySet, associationSet.TargetSet);
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:25,代码来源:AssociationSetTests.cs


示例2: AssociationSetMetadata

        /// <summary>
        ///     Initialize Metadata for an AssociationSet
        /// </summary>
        internal AssociationSetMetadata(Set<EntitySet> affectedTables, AssociationSet associationSet, MetadataWorkspace workspace)
        {
            // If there is only 1 table, there can be no ambiguity about the "destination" of a relationship, so such
            // sets are not typically required.
            var isRequired = 1 < affectedTables.Count;

            // determine the ends of the relationship
            var ends = associationSet.AssociationSetEnds;

            // find collocated entities
            foreach (var table in affectedTables)
            {
                // Find extents influencing the table
                var influencingExtents = MetadataHelper.GetInfluencingEntitySetsForTable(table, workspace);

                foreach (var influencingExtent in influencingExtents)
                {
                    foreach (var end in ends)
                    {
                        // If the extent is an end of the relationship and we haven't already added it to the
                        // required set...
                        if (end.EntitySet.EdmEquals(influencingExtent))
                        {
                            if (isRequired)
                            {
                                AddEnd(ref RequiredEnds, end.CorrespondingAssociationEndMember);
                            }
                            else if (null == RequiredEnds
                                     || !RequiredEnds.Contains(end.CorrespondingAssociationEndMember))
                            {
                                AddEnd(ref OptionalEnds, end.CorrespondingAssociationEndMember);
                            }
                        }
                    }
                }
            }

            // fix Required and Optional sets
            FixSet(ref RequiredEnds);
            FixSet(ref OptionalEnds);

            // for associations with referential constraints, the principal end is always interesting
            // since its key values may take precedence over the key values of the dependent end
            foreach (var constraint in associationSet.ElementType.ReferentialConstraints)
            {
                // FromRole is the principal end in the referential constraint
                var principalEnd = (AssociationEndMember)constraint.FromRole;

                if (!RequiredEnds.Contains(principalEnd)
                    &&
                    !OptionalEnds.Contains(principalEnd))
                {
                    AddEnd(ref IncludedValueEnds, principalEnd);
                }
            }

            FixSet(ref IncludedValueEnds);
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:61,代码来源:AssociationSetMetadata.cs


示例3: Visit

 protected virtual void Visit(AssociationSet associationSet)
 {
     Visit(associationSet.ElementType);
     Visit(associationSet.EntityContainer);
     foreach (var end in associationSet.AssociationSetEnds)
     {
         Visit(end);
     }
 }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:9,代码来源:basemetadatamappingvisitor.cs


示例4: Can_get_association_set

        public void Can_get_association_set()
        {
            var entitySet = new EntitySet();
            var associationSet = new AssociationSet("AS", new AssociationType());

            var associationSetMapping
                = new StorageAssociationSetMapping(associationSet, entitySet);

            Assert.Same(associationSet, associationSetMapping.AssociationSet);
        }
开发者ID:jwanagel,项目名称:jjwtest,代码行数:10,代码来源:StorageAssociationSetMappingTests.cs


示例5: Can_get_association_set

        public void Can_get_association_set()
        {
            var entitySet = new EntitySet();
            var associationSet = new AssociationSet("AS", new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace));

            var associationSetMapping
                = new StorageAssociationSetMapping(associationSet, entitySet);

            Assert.Same(associationSet, associationSetMapping.AssociationSet);
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:10,代码来源:StorageAssociationSetMappingTests.cs


示例6: Can_get_table

        public void Can_get_table()
        {
            var entityType = new EntityType();
            var entitySet = new EntitySet("ES", null, null, null, entityType);
            var associationSet = new AssociationSet("AS", new AssociationType());

            var associationSetMapping
                = new StorageAssociationSetMapping(associationSet, entitySet);

            Assert.Same(entityType, associationSetMapping.Table);
        }
开发者ID:jwanagel,项目名称:jjwtest,代码行数:11,代码来源:StorageAssociationSetMappingTests.cs


示例7: StorageAssociationSetModificationFunctionMapping

        internal StorageAssociationSetModificationFunctionMapping(
            AssociationSet associationSet,
            StorageModificationFunctionMapping deleteFunctionMapping,
            StorageModificationFunctionMapping insertFunctionMapping)
        {
            Contract.Requires(associationSet != null);

            AssociationSet = associationSet;
            DeleteFunctionMapping = deleteFunctionMapping;
            InsertFunctionMapping = insertFunctionMapping;
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:11,代码来源:StorageAssociationSetModificationFunctionMapping.cs


示例8: AssociationSetModificationFunctionMapping

        /// <summary>
        /// Initalizes a new AssociationSetModificationFunctionMapping instance.
        /// </summary>
        /// <param name="associationSet">An association set.</param>
        /// <param name="deleteFunctionMapping">A delete function mapping.</param>
        /// <param name="insertFunctionMapping">An insert function mapping.</param>
        public AssociationSetModificationFunctionMapping(
            AssociationSet associationSet,
            ModificationFunctionMapping deleteFunctionMapping,
            ModificationFunctionMapping insertFunctionMapping)
        {
            Check.NotNull(associationSet, "associationSet");

            _associationSet = associationSet;
            _deleteFunctionMapping = deleteFunctionMapping;
            _insertFunctionMapping = insertFunctionMapping;
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:17,代码来源:AssociationSetModificationFunctionMapping.cs


示例9: StorageAssociationSetModificationFunctionMapping

        internal StorageAssociationSetModificationFunctionMapping(
            AssociationSet associationSet,
            StorageModificationFunctionMapping deleteFunctionMapping,
            StorageModificationFunctionMapping insertFunctionMapping)
        {
            DebugCheck.NotNull(associationSet);

            AssociationSet = associationSet;
            DeleteFunctionMapping = deleteFunctionMapping;
            InsertFunctionMapping = insertFunctionMapping;
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:11,代码来源:StorageAssociationSetModificationFunctionMapping.cs


示例10: AssociationSetMapping

        /// <summary>
        /// Initializes a new AssociationSetMapping instance.
        /// </summary>
        /// <param name="associationSet">The association set to be mapped.</param>
        /// <param name="storeEntitySet">The store entity set to be mapped.</param>
        /// <param name="containerMapping">The parent container mapping.</param>
        public AssociationSetMapping(AssociationSet associationSet, EntitySet storeEntitySet, EntityContainerMapping containerMapping)
            : base(containerMapping)
        {
            Check.NotNull(associationSet, "associationSet");
            Check.NotNull(storeEntitySet, "storeEntitySet");

            _associationSet = associationSet;
            _associationTypeMapping = new AssociationTypeMapping(associationSet.ElementType, this);
            _associationTypeMapping.MappingFragment
                = new MappingFragment(storeEntitySet, _associationTypeMapping, false);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:17,代码来源:AssociationSetMapping.cs


示例11: Can_get_table

        public void Can_get_table()
        {
            var entityType = new EntityType("E", "N", DataSpace.CSpace);
            var entitySet = new EntitySet("ES", null, null, null, entityType);
            var associationSet = new AssociationSet("AS", new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace));

            var associationSetMapping
                = new StorageAssociationSetMapping(associationSet, entitySet);

            Assert.Same(entityType, associationSetMapping.Table);
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:11,代码来源:StorageAssociationSetMappingTests.cs


示例12: Cannot_create_with_null_argument

        public void Cannot_create_with_null_argument()
        {
            var associationType = new AssociationType("AT", "N", false, DataSpace.CSpace);
            var associationSet = new AssociationSet("AS", associationType);

            Assert.Equal(
                "members",
                Assert.Throws<ArgumentNullException>(
                    () => new ModificationFunctionMemberPath(
                        null, associationSet)).ParamName);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:11,代码来源:MidificationFunctionMemberPathTests.cs


示例13: 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


示例14: ModificationFunctionMemberPath

        /// <summary>
        /// Initializes a new ModificationFunctionMemberPath instance.
        /// </summary>
        /// <param name="members">Gets the members in the path from the leaf (the member being bound)
        /// to the root of the structure.</param>
        /// <param name="associationSet">Gets the association set to which we are navigating 
        /// via this member. If the value is null, this is not a navigation member path.</param>
        public ModificationFunctionMemberPath(IEnumerable<EdmMember> members, AssociationSet associationSet)
        {
            Check.NotNull(members, "members");

            _members = new ReadOnlyCollection<EdmMember>(new List<EdmMember>(members));

            if (null != associationSet)
            {
                Debug.Assert(2 == Members.Count, "Association bindings must always consist of the end and the key");

                // find the association set end
                _associationSetEnd = associationSet.AssociationSetEnds[Members[1].Name];
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:21,代码来源:ModificationFunctionMemberPath.cs


示例15: StorageModificationFunctionMemberPath

        internal StorageModificationFunctionMemberPath(IEnumerable<EdmMember> members, AssociationSet associationSetNavigation)
        {
            Contract.Requires(members != null);

            Members = new ReadOnlyCollection<EdmMember>(new List<EdmMember>(members));

            if (null != associationSetNavigation)
            {
                Debug.Assert(2 == Members.Count, "Association bindings must always consist of the end and the key");

                // find the association set end
                AssociationSetEnd = associationSetNavigation.AssociationSetEnds[Members[1].Name];
            }
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:14,代码来源:StorageModificationFunctionMemberPath.cs


示例16: VisitEdmAssociationSet

 public override void VisitEdmAssociationSet(AssociationSet item)
 {
     _schemaWriter.WriteAssociationSetElementHeader(item);
     base.VisitEdmAssociationSet(item);
     if (item.SourceSet != null)
     {
         _schemaWriter.WriteAssociationSetEndElement(item.SourceSet, item.ElementType.SourceEnd.Name);
     }
     if (item.TargetSet != null)
     {
         _schemaWriter.WriteAssociationSetEndElement(item.TargetSet, item.ElementType.TargetEnd.Name);
     }
     _schemaWriter.WriteEndElement();
 }
开发者ID:jwanagel,项目名称:jjwtest,代码行数:14,代码来源:EdmSerializationVisitor.cs


示例17: Can_remove_set_from_container

        public void Can_remove_set_from_container()
        {
            var entityContainer = new EntityContainer("C", DataSpace.CSpace);
            var associationSet = new AssociationSet("A", new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace));

            entityContainer.AddEntitySetBase(associationSet);

            Assert.Equal(1, entityContainer.AssociationSets.Count);

            entityContainer.RemoveEntitySetBase(associationSet);

            Assert.Empty(entityContainer.AssociationSets);
            Assert.Null(associationSet.EntityContainer);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:14,代码来源:EntityContainerTests.cs


示例18: Create_should_return_only_fk_associations

            public void Create_should_return_only_fk_associations()
            {
                var filter = new ViewgenContext.OneToOneFkAssociationsForEntitiesFilter();

                var associationType1
                    = new AssociationType("A1", EdmConstants.TransientNamespace, true, DataSpace.CSpace);

                var entityType = new EntityType("E", "N", DataSpace.CSpace);

                associationType1.AddMember(
                    new AssociationEndMember("S", entityType)
                        {
                            RelationshipMultiplicity = RelationshipMultiplicity.One
                        });
                associationType1.AddMember(
                    new AssociationEndMember("T", entityType)
                        {
                            RelationshipMultiplicity = RelationshipMultiplicity.One
                        });

                associationType1.SetReadOnly();

                var associationSet1 = new AssociationSet("AS1", associationType1);

                var associationType2
                    = new AssociationType("A2", EdmConstants.TransientNamespace, false, DataSpace.CSpace);

                associationType2.AddMember(
                    new AssociationEndMember("S", entityType)
                        {
                            RelationshipMultiplicity = RelationshipMultiplicity.One
                        });
                associationType2.AddMember(
                    new AssociationEndMember("T", entityType)
                        {
                            RelationshipMultiplicity = RelationshipMultiplicity.One
                        });

                associationType2.SetReadOnly();

                var associationSet2 = new AssociationSet("AS2", associationType2);

                var query
                    = filter.Filter(
                        new[] { entityType },
                        new[] { associationSet1, associationSet2 });

                Assert.Same(associationSet1, query.Single());
            }
开发者ID:christiandpena,项目名称:entityframework,代码行数:49,代码来源:ViewgenContextTests.cs


示例19: StorageAssociationSetMapping

        internal StorageAssociationSetMapping(AssociationSet extent, EntitySet entitySet)
            : base(extent, null)
        {
            DebugCheck.NotNull(entitySet);

            var associationTypeMapping
                = new StorageAssociationTypeMapping(extent.ElementType, this);

            var mappingFragment
                = new StorageMappingFragment(entitySet, associationTypeMapping, false);

            associationTypeMapping.AddFragment(mappingFragment);

            AddTypeMapping(associationTypeMapping);
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:15,代码来源:StorageAssociationSetMapping.cs


示例20: AppendDropForeignKeys

        private void AppendDropForeignKeys(AssociationSet associationSet)
        {
            var constraint = associationSet.ElementType.ReferentialConstraints.Single();
            var principalEnd = associationSet.AssociationSetEnds[constraint.FromRole.Name];
            var dependentEnd = associationSet.AssociationSetEnds[constraint.ToRole.Name];

            AppendObjectExistenceCheck(QuoteIdentifier(GetSchemaName(dependentEnd.EntitySet)) + "." + QuoteIdentifier(associationSet.Name), "F");
            AppendNewLine();
            AppendSql("alter table ");
            AppendTableName(dependentEnd.EntitySet);
            AppendSql(" drop constraint ");
            AppendIdentifier(associationSet.Name);
            AppendSql(";");
            AppendNewLine();
        }
开发者ID:Kooboo,项目名称:Ecommerce,代码行数:15,代码来源:SqlScripts.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Edm.AssociationType类代码示例发布时间:2022-05-26
下一篇:
C# Edm.AssociationEndMember类代码示例发布时间: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