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


C# EdmModel.GetEntitySets方法代码示例

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


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

示例1: GetEntitySets_should_return_all_sets

        public void GetEntitySets_should_return_all_sets()
        {
            var model = new EdmModel(DataSpace.CSpace);
            model.AddEntitySet("S", new EntityType("E", "N", DataSpace.CSpace));
            model.AddEntitySet("T", new EntityType("E", "N", DataSpace.CSpace));

            Assert.Equal(2, model.GetEntitySets().Count());
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:8,代码来源:EdmModelExtensionsTests.cs

示例2: Configure

        internal override void Configure(
            AssociationSetMapping associationSetMapping, EdmModel database, PropertyInfo navigationProperty)
        {
            DebugCheck.NotNull(associationSetMapping);

            DebugCheck.NotNull(navigationProperty);

            // By convention source end contains the dependent column mappings
            var propertyMappings = associationSetMapping.SourceEndMapping.PropertyMappings.ToList();

            if (_tableName != null)
            {
                var targetTable
                    = ((from t in database.EntityTypes
                        let n = t.GetTableName()
                        where (n != null && n.Equals(_tableName))
                        select t)
                          .SingleOrDefault())
                      ?? (from es in database.GetEntitySets()
                          where string.Equals(es.Table, _tableName.Name, StringComparison.Ordinal)
                          select es.ElementType).SingleOrDefault();

                if (targetTable == null)
                {
                    throw Error.TableNotFound(_tableName);
                }

                var sourceTable = associationSetMapping.Table;

                if (sourceTable != targetTable)
                {
                    var foreignKeyConstraint
                        = sourceTable.ForeignKeyBuilders
                                     .Single(fk => fk.DependentColumns.SequenceEqual(propertyMappings.Select(pm => pm.Column)));

                    sourceTable.RemoveForeignKey(foreignKeyConstraint);
                    targetTable.AddForeignKey(foreignKeyConstraint);

                    foreignKeyConstraint.DependentColumns
                                        .Each(
                                            c =>
                                            {
                                                var isKey = c.IsPrimaryKeyColumn;

                                                sourceTable.RemoveMember(c);
                                                targetTable.AddMember(c);

                                                if (isKey)
                                                {
                                                    targetTable.AddKeyMember(c);
                                                }
                                            });

                    associationSetMapping.StoreEntitySet = database.GetEntitySet(targetTable);
                }
            }

            if ((_keyColumnNames.Count > 0)
                && (_keyColumnNames.Count != propertyMappings.Count()))
            {
                throw Error.IncorrectColumnCount(string.Join(", ", _keyColumnNames));
            }

            _keyColumnNames.Each((n, i) => propertyMappings[i].Column.Name = n);

            foreach (var annotation in _annotations)
            {
                var index = _keyColumnNames.IndexOf(annotation.Key.Item1);

                if (index == -1)
                {
                    throw new InvalidOperationException(Strings.BadKeyNameForAnnotation(annotation.Key.Item1, annotation.Key.Item2));
                }

                propertyMappings[index].Column.AddAnnotation(
                    XmlConstants.CustomAnnotationPrefix + annotation.Key.Item2,
                    annotation.Value);
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:79,代码来源:ForeignKeyAssociationMappingConfiguration.cs

示例3: ConfigureEntitySetName

        private void ConfigureEntitySetName(EntityType entityType, EdmModel model)
        {
            DebugCheck.NotNull(entityType);
            DebugCheck.NotNull(model);

            if ((EntitySetName == null)
                || (entityType.BaseType != null))
            {
                return;
            }

            var entitySet = model.GetEntitySet(entityType);

            Debug.Assert(entitySet != null);

            entitySet.Name
                = model.GetEntitySets().Except(new[] { entitySet }).UniquifyName(EntitySetName);

            entitySet.SetConfiguration(this);
        }
开发者ID:hallco978,项目名称:entityframework,代码行数:20,代码来源:EntityTypeConfiguration.cs


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