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


C# EntityType.GetMetadataProperties方法代码示例

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


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

示例1: Generate_should_flatten_complex_properties_to_columns

        public void Generate_should_flatten_complex_properties_to_columns()
        {
            var databaseMapping = CreateEmptyModel();
            var entityType = new EntityType("E", "N", DataSpace.CSpace);
            var complexType = new ComplexType("C");

            var property = EdmProperty.CreatePrimitive("P1", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));

            complexType.AddMember(property);
            entityType.AddComplexProperty("C1", complexType);
            var property1 = EdmProperty.CreatePrimitive("P2", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));

            entityType.AddMember(property1);
            var entitySet = databaseMapping.Model.AddEntitySet("ESet", entityType);
            var type = typeof(object);

            entityType.GetMetadataProperties().SetClrType(type);

            new TableMappingGenerator(ProviderRegistry.Sql2008_ProviderManifest).Generate(entityType, databaseMapping);

            var entityTypeMappingFragment
                = databaseMapping.GetEntitySetMapping(entitySet).EntityTypeMappings.Single().MappingFragments.Single();

            Assert.Equal(2, entityTypeMappingFragment.ColumnMappings.Count());
            Assert.Equal(2, entityTypeMappingFragment.Table.Properties.Count());
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:26,代码来源:TableMappingGeneratorTests.cs

示例2: Can_get_and_set_configuration_annotation

        public void Can_get_and_set_configuration_annotation()
        {
            var entityType = new EntityType("E", "N", DataSpace.CSpace);

            entityType.GetMetadataProperties().SetConfiguration(42);

            Assert.Equal(42, entityType.GetConfiguration());
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:8,代码来源:EntityTypeExtensionsTests.cs

示例3: GetClrType_returns_CLR_type_annotation_for_EntityType

        public void GetClrType_returns_CLR_type_annotation_for_EntityType()
        {
            var entityType = new EntityType("E", "N", DataSpace.CSpace);

            Assert.Null(((EdmType)entityType).GetClrType());

            entityType.GetMetadataProperties().SetClrType(typeof(Random));

            Assert.Same(typeof(Random), ((EdmType)entityType).GetClrType());
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:10,代码来源:EdmTypeExtensionsTests.cs

示例4: Can_get_and_set_clr_type_annotation

        public void Can_get_and_set_clr_type_annotation()
        {
            var entityType = new EntityType("E", "N", DataSpace.CSpace);

            Assert.Null(entityType.GetClrType());

            var type = typeof(object);

            entityType.GetMetadataProperties().SetClrType(type);

            Assert.Equal(typeof(object), entityType.GetClrType());
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:12,代码来源:EntityTypeExtensionsTests.cs

示例5: Entity

        public TestModelBuilder Entity(string name, bool addSet = true)
        {
            _entityType = _model.AddEntityType(name);

            Type type = new MockType(name);

            _entityType.GetMetadataProperties().SetClrType(type);

            if (addSet)
            {
                _model.AddEntitySet(name + "Set", _entityType);
            }

            return this;
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:15,代码来源:TestModelBuilder.cs

示例6: Apply_should_move_declared_keys_head_of_declared_properties_list

        public void Apply_should_move_declared_keys_head_of_declared_properties_list()
        {
            var entityType = new EntityType("E", "N", DataSpace.CSpace);
            var type = typeof(SimpleEntity);

            entityType.GetMetadataProperties().SetClrType(type);

            var property1 = EdmProperty.CreatePrimitive("PrivateProperty", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));

            entityType.AddMember(property1);

            var property2 = EdmProperty.CreatePrimitive("InheritedPropertyB", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));

            entityType.AddMember(property2);

            var property3 = EdmProperty.CreatePrimitive("InheritedPropertyA", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));

            entityType.AddMember(property3);

            var property4 = EdmProperty.CreatePrimitive("PropertyB", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));

            entityType.AddMember(property4);

            var property5 = EdmProperty.CreatePrimitive("PropertyA", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));

            entityType.AddMember(property5);

            var property6 = EdmProperty.CreatePrimitive("Key", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));

            entityType.AddMember(property6);

            entityType.AddKeyMember(property6);

            new DeclaredPropertyOrderingConvention().Apply(entityType, new DbModel(new EdmModel(DataSpace.CSpace), null));

            Assert.True(
                entityType.DeclaredProperties.Select(e => e.Name)
                    .SequenceEqual(
                        new[]
                            {
                                "Key",
                                "PrivateProperty",
                                "PropertyA",
                                "PropertyB",
                                "InheritedPropertyA",
                                "InheritedPropertyB"
                            }));
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:48,代码来源:DeclaredPropertyOrderingConventionTests.cs

示例7: Generate_should_add_set_mapping_and_table_and_set_clr_type

        public void Generate_should_add_set_mapping_and_table_and_set_clr_type()
        {
            var databaseMapping = CreateEmptyModel();
            var entityType = new EntityType("E", "N", DataSpace.CSpace);
            var entitySet = databaseMapping.Model.AddEntitySet("ESet", entityType);
            var type = typeof(object);

            entityType.GetMetadataProperties().SetClrType(type);

            new TableMappingGenerator(ProviderRegistry.Sql2008_ProviderManifest).Generate(entityType, databaseMapping);

            Assert.NotNull(databaseMapping.GetEntitySetMapping(entitySet));
            Assert.Same(entityType, databaseMapping.GetEntitySetMapping(entitySet).EntityTypeMappings.Single().EntityType);
            Assert.Same(typeof(object), databaseMapping.GetEntitySetMapping(entitySet).EntityTypeMappings.Single().GetClrType());
            Assert.NotNull(databaseMapping.GetEntitySetMapping(entitySet).EntityTypeMappings.Single().MappingFragments.Single().Table);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:16,代码来源:TableMappingGeneratorTests.cs

示例8: Configure_should_add_properties_to_dependent_properties

        public void Configure_should_add_properties_to_dependent_properties()
        {
            var mockPropertyInfo = new MockPropertyInfo(typeof(int), "P");
            var constraintConfiguration = new ForeignKeyConstraintConfiguration(new[] { mockPropertyInfo.Object });
            var entityType = new EntityType("SE", "N", DataSpace.CSpace);
            entityType.GetMetadataProperties().SetClrType(typeof(object));
            var property1 = EdmProperty.CreatePrimitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));

            entityType.AddMember(property1);
            var property = property1;
            property.SetClrPropertyInfo(mockPropertyInfo);
            var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace);
            associationType.SourceEnd = new AssociationEndMember("S", entityType);
            associationType.TargetEnd = new AssociationEndMember("T", new EntityType("TE", "N", DataSpace.CSpace));

            constraintConfiguration.Configure(
                associationType, associationType.SourceEnd, new EntityTypeConfiguration(typeof(object)));

            Assert.Equal(1, associationType.Constraint.ToProperties.Count);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:20,代码来源:ForeignKeyConstraintConfigurationTests.cs

示例9: Apply_should_match_key_that_is_an_fk_used_in_table_splitting

        public void Apply_should_match_key_that_is_an_fk_used_in_table_splitting()
        {
            var model = new EdmModel(DataSpace.CSpace);
            var entityType = new EntityType("E", "N", DataSpace.CSpace);
            var property = EdmProperty.CreatePrimitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int64));

            entityType.AddKeyMember(property);

            var targetConfig = new EntityTypeConfiguration(typeof(object));
            targetConfig.ToTable("SharedTable");
            entityType.GetMetadataProperties().SetConfiguration(targetConfig);

            var sourceEntityType = new EntityType("E", "N", DataSpace.CSpace);
            var sourceConfig = new EntityTypeConfiguration(typeof(object));
            sourceConfig.ToTable("SharedTable");
            sourceEntityType.GetMetadataProperties().SetConfiguration(sourceConfig);

            var associationType
                = model.AddAssociationType(
                    "A", sourceEntityType, RelationshipMultiplicity.One,
                    entityType, RelationshipMultiplicity.One);

            associationType.Constraint
                = new ReferentialConstraint(
                    associationType.SourceEnd,
                    associationType.TargetEnd,
                    new[] { property },
                    new[] { property });

            (new StoreGeneratedIdentityKeyConvention())
                .Apply(entityType, new DbModel(model, null));

            Assert.Equal(
                StoreGeneratedPattern.Identity,
                entityType.KeyProperties.Single().GetStoreGeneratedPattern());
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:36,代码来源:StoreGeneratedIdentityKeyConventionTests.cs

示例10: Configure_should_throw_when_dependent_property_not_found

        public void Configure_should_throw_when_dependent_property_not_found()
        {
            var constraintConfiguration
                = new ForeignKeyConstraintConfiguration(
                    new[]
                        {
                            new MockPropertyInfo(typeof(int), "P").Object
                        });
            var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace);

            var entityType = new EntityType("T", "N", DataSpace.CSpace);
            entityType.GetMetadataProperties().SetClrType(typeof(object));

            Assert.Equal(
                Strings.ForeignKeyPropertyNotFound("P", "T"),
                Assert.Throws<InvalidOperationException>(
                    () => constraintConfiguration.Configure(
                        associationType,
                        new AssociationEndMember("E", entityType)
                              , new EntityTypeConfiguration(typeof(object)))).Message);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:21,代码来源:ForeignKeyConstraintConfigurationTests.cs

示例11: Configure

        internal virtual void Configure(EntityType entityType, EdmModel model)
        {
            DebugCheck.NotNull(entityType);
            DebugCheck.NotNull(model);

            ConfigureKey(entityType);
            Configure(entityType.Name, entityType.Properties, entityType.GetMetadataProperties());
            ConfigureAssociations(entityType, model);
            ConfigureEntitySetName(entityType, model);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:10,代码来源:EntityTypeConfiguration.cs

示例12: GetEntityTypeMapping_should_return_mapping_for_type_by_clrType

        public void GetEntityTypeMapping_should_return_mapping_for_type_by_clrType()
        {
            var databaseMapping = new DbDatabaseMapping()
                .Initialize(new EdmModel(DataSpace.CSpace), new EdmModel(DataSpace.SSpace));
            var entityType = new EntityType("Foo", "N", DataSpace.CSpace);
            var type = typeof(object);

            entityType.GetMetadataProperties().SetClrType(type);
            var entityTypeMapping = new EntityTypeMapping(null);
            entityTypeMapping.AddType(entityType);
            entityTypeMapping.SetClrType(typeof(object));
            databaseMapping.AddEntitySetMapping(
                new EntitySet
                    {
                        Name = "ES"
                    }).AddTypeMapping(entityTypeMapping);

            Assert.Same(entityTypeMapping, databaseMapping.GetEntityTypeMapping(typeof(object)));
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:19,代码来源:DbDatabaseMappingExtensionsTests.cs


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