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


C# EdmEntityType.SetClrType方法代码示例

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


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

示例1: 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 EdmEntityType();
            entityType.SetClrType(typeof(SimpleEntity));
            entityType.AddPrimitiveProperty("StaticProperty");
            entityType.AddPrimitiveProperty("PrivateProperty");
            entityType.AddPrimitiveProperty("InheritedPropertyB");
            entityType.AddPrimitiveProperty("InheritedPropertyA");
            entityType.AddPrimitiveProperty("PropertyB");
            entityType.AddPrimitiveProperty("PropertyA");
            entityType.DeclaredKeyProperties.Add(
                entityType.AddPrimitiveProperty("Key"));

            ((IEdmConvention<EdmEntityType>)new DeclaredPropertyOrderingConvention())
                .Apply(entityType, new EdmModel());

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

示例2: Can_get_and_set_clr_type_annotation

        public void Can_get_and_set_clr_type_annotation()
        {
            var entityType = new EdmEntityType();

            Assert.Null(entityType.GetClrType());

            entityType.SetClrType(typeof(object));

            Assert.Equal(typeof(object), entityType.GetClrType());
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:10,代码来源:EdmEntityTypeExtensionsTests.cs

示例3: Entity

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

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

            return this;
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:12,代码来源:TestModelBuilder.cs

示例4: 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 EdmEntityType { Name = "E" };
            var entitySet = databaseMapping.Model.AddEntitySet("ESet", entityType);
            entityType.SetClrType(typeof(object));

            new EntityTypeMappingGenerator(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().TypeMappingFragments.Single().Table);
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:14,代码来源:EntityTypeMappingGeneratorTests.cs

示例5: Generate_should_map_scalar_properties_to_columns

        public void Generate_should_map_scalar_properties_to_columns()
        {
            var databaseMapping = CreateEmptyModel();
            var entityType = new EdmEntityType { Name = "E" };
            entityType.AddPrimitiveProperty("P1").PropertyType.EdmType = EdmPrimitiveType.Int32;
            entityType.AddPrimitiveProperty("P2").PropertyType.EdmType = EdmPrimitiveType.String;
            var entitySet = databaseMapping.Model.AddEntitySet("ESet", entityType);
            entityType.SetClrType(typeof(object));

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

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

            Assert.Equal(2, entityTypeMappingFragment.PropertyMappings.Count());
            Assert.Equal(2, entityTypeMappingFragment.Table.Columns.Count());
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:17,代码来源:EntityTypeMappingGeneratorTests.cs

示例6: 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().Initialize(), new DbDatabaseMetadata());
            var entityType = new EdmEntityType { Name = "Foo" };
            entityType.SetClrType(typeof(object));
            var entityTypeMapping = new DbEntityTypeMapping { EntityType = entityType };
            entityTypeMapping.SetClrType(typeof(object));
            databaseMapping.AddEntitySetMapping(new EdmEntitySet()).EntityTypeMappings.Add(entityTypeMapping);

            Assert.Same(entityTypeMapping, databaseMapping.GetEntityTypeMapping(typeof(object)));
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:12,代码来源:DbModelExtensionsTests.cs


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