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

C# Edm.EdmModel类代码示例

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

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



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

示例1: Configure_should_configure_inverse

        public void Configure_should_configure_inverse()
        {
            var inverseMockPropertyInfo = new MockPropertyInfo();
            var navigationPropertyConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo())
                                                      {
                                                          InverseNavigationProperty = inverseMockPropertyInfo
                                                      };
            var associationType = new EdmAssociationType().Initialize();
            var inverseAssociationType = new EdmAssociationType().Initialize();
            var model = new EdmModel().Initialize();
            model.AddAssociationType(inverseAssociationType);
            var inverseNavigationProperty
                = model.AddEntityType("T")
                    .AddNavigationProperty("N", inverseAssociationType);
            inverseNavigationProperty.SetClrPropertyInfo(inverseMockPropertyInfo);

            navigationPropertyConfiguration.Configure(
                new EdmNavigationProperty
                    {
                        Association = associationType
                    }, model, new EntityTypeConfiguration(typeof(object)));

            Assert.Same(associationType, inverseNavigationProperty.Association);
            Assert.Same(associationType.SourceEnd, inverseNavigationProperty.ResultEnd);
            Assert.Equal(0, model.GetAssociationTypes().Count());
        }
开发者ID:junxy,项目名称:entityframework,代码行数:26,代码来源:NavigationPropertyConfigurationTests.cs


示例2: MapComplexType_should_not_map_invalid_structural_type

        public void MapComplexType_should_not_map_invalid_structural_type()
        {
            var model = new EdmModel().Initialize();
            var typeMapper = new TypeMapper(new MappingContext(new ModelConfiguration(), new ConventionsConfiguration(), model));

            Assert.Null(typeMapper.MapComplexType(typeof(string)));
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:7,代码来源:TypeMapperTests.cs


示例3: Generate_should_correctly_map_string_primitive_property_facets

        public void Generate_should_correctly_map_string_primitive_property_facets()
        {
            var model = new EdmModel().Initialize();
            var entityType = model.AddEntityType("E");
            entityType.SetClrType(typeof(object));
            model.AddEntitySet("ESet", entityType);
            var property = entityType.AddPrimitiveProperty("P");
            property.PropertyType.EdmType = EdmPrimitiveType.String;

            property.PropertyType.IsNullable = false;
            property.PropertyType.PrimitiveTypeFacets.IsFixedLength = true;
            property.PropertyType.PrimitiveTypeFacets.IsMaxLength = true;
            property.PropertyType.PrimitiveTypeFacets.IsUnicode = true;
            property.PropertyType.PrimitiveTypeFacets.MaxLength = 42;
            property.PropertyType.PrimitiveTypeFacets.Precision = 23;
            property.PropertyType.PrimitiveTypeFacets.Scale = 77;
            property.SetStoreGeneratedPattern(DbStoreGeneratedPattern.Identity);

            var databaseMapping = new DatabaseMappingGenerator(ProviderRegistry.Sql2008_ProviderManifest).Generate(model);

            var column = databaseMapping.GetEntityTypeMapping(entityType).TypeMappingFragments.Single().PropertyMappings.Single().Column;

            Assert.False(column.IsNullable);
            Assert.Null(column.Facets.IsFixedLength);
            Assert.Equal(true, column.Facets.IsMaxLength);
            Assert.Null(column.Facets.IsUnicode);
            Assert.Equal(42, column.Facets.MaxLength);
            Assert.Null(column.Facets.Precision);
            Assert.Null(column.Facets.Scale);
            Assert.Equal(DbStoreGeneratedPattern.Identity, column.StoreGeneratedPattern);
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:31,代码来源:DatabaseMappingGeneratorTests.cs


示例4: GetClrTypes_should_return_ospace_types

        public void GetClrTypes_should_return_ospace_types()
        {
            var model = new EdmModel().Initialize();
            model.AddEntityType("A").SetClrType(typeof(object));
            model.AddEntityType("B").SetClrType(typeof(string));

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


示例5: Can_get_and_set_provider_info_annotation

        public void Can_get_and_set_provider_info_annotation()
        {
            var model = new EdmModel();
            var providerInfo = ProviderRegistry.Sql2008_ProviderInfo;

            model.SetProviderInfo(providerInfo);

            Assert.Same(providerInfo, model.GetProviderInfo());
        }
开发者ID:junxy,项目名称:entityframework,代码行数:9,代码来源:EdmModelExtensionsTests.cs


示例6: Apply_should_ignore_current_entity_set

        public void Apply_should_ignore_current_entity_set()
        {
            var model = new EdmModel().Initialize();
            var entitySet = model.AddEntitySet("Cats", new EdmEntityType());

            ((IEdmConvention<EdmEntitySet>)new PluralizingEntitySetNameConvention())
                .Apply(entitySet, model);

            Assert.Equal("Cats", entitySet.Name);
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:10,代码来源:PluralizingEntitySetNameConventionTests.cs


示例7: ApplyModel_should_run_model_conventions

        public void ApplyModel_should_run_model_conventions()
        {
            var model = new EdmModel().Initialize();
            var mockConvention = new Mock<IEdmConvention>();
            var conventionsConfiguration = new ConventionsConfiguration(new[] { mockConvention.Object });

            conventionsConfiguration.ApplyModel(model);

            mockConvention.Verify(c => c.Apply(model), Times.AtMostOnce());
        }
开发者ID:junxy,项目名称:entityframework,代码行数:10,代码来源:ConventionsConfigurationTests.cs


示例8: Generate_should_initialize_mapping_model

        public void Generate_should_initialize_mapping_model()
        {
            var model = new EdmModel().Initialize();

            var databaseMapping = new DatabaseMappingGenerator(ProviderRegistry.Sql2008_ProviderManifest).Generate(model);

            Assert.NotNull(databaseMapping);
            Assert.NotNull(databaseMapping.Database);
            Assert.Same(model.Containers.Single(), databaseMapping.EntityContainerMappings.Single().EntityContainer);
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:10,代码来源:DatabaseMappingGeneratorTests.cs


示例9: InitializeDatabaseMapping

        private static DbDatabaseMapping InitializeDatabaseMapping(EdmModel model)
        {
            //Contract.Requires(model != null);

            var databaseMapping = new DbDatabaseMapping().Initialize(
                model, new DbDatabaseMetadata().Initialize(model.Version));

            databaseMapping.EntityContainerMappings.Single().EntityContainer = model.Containers.Single();

            return databaseMapping;
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:11,代码来源:DatabaseMappingGenerator.cs


示例10: FixNavigationProperties

 private static void FixNavigationProperties(
     EdmModel model, EdmAssociationType unifiedAssociation, EdmAssociationType redundantAssociation)
 {
     foreach (var navigationProperty
         in model.GetEntityTypes()
             .SelectMany(e => e.NavigationProperties)
             .Where(np => np.Association == redundantAssociation))
     {
         navigationProperty.Association = unifiedAssociation;
         navigationProperty.ResultEnd = unifiedAssociation.SourceEnd;
     }
 }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:12,代码来源:AssociationInverseDiscoveryConvention.cs


示例11: Generate

        public DbDatabaseMapping Generate(EdmModel model)
        {
            //Contract.Requires(model != null);

            var databaseMapping = InitializeDatabaseMapping(model);

            GenerateEntityTypes(model, databaseMapping);
            GenerateDiscriminators(databaseMapping);
            GenerateAssociationTypes(model, databaseMapping);

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


示例12: MapComplexType_should_not_map_ignored_type

        public void MapComplexType_should_not_map_ignored_type()
        {
            var model = new EdmModel().Initialize();
            var mockModelConfiguration = new Mock<ModelConfiguration>();
            var typeMapper = new TypeMapper(new MappingContext(mockModelConfiguration.Object, new ConventionsConfiguration(), model));
            var mockType = new MockType("Foo");
            mockModelConfiguration.Setup(m => m.IsIgnoredType(mockType)).Returns(true);

            var complexType = typeMapper.MapComplexType(mockType);

            Assert.Null(complexType);
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:12,代码来源:TypeMapperTests.cs


示例13: HasCascadeDeletePath_should_return_true_for_self_ref_cascade

        public void HasCascadeDeletePath_should_return_true_for_self_ref_cascade()
        {
            var model = new EdmModel().Initialize();
            var entityType = model.AddEntityType("A");
            var associationType = new EdmAssociationType().Initialize();
            associationType.SourceEnd.EntityType
                = associationType.TargetEnd.EntityType
                  = entityType;
            associationType.SourceEnd.DeleteAction = EdmOperationAction.Cascade;
            model.AddAssociationType(associationType);

            Assert.True(model.HasCascadeDeletePath(entityType, entityType));
        }
开发者ID:junxy,项目名称:entityframework,代码行数:13,代码来源:EdmModelExtensionsTests.cs


示例14: Map_should_not_detect_arrays_as_collection_associations

        public void Map_should_not_detect_arrays_as_collection_associations()
        {
            var modelConfiguration = new ModelConfiguration();
            var model = new EdmModel().Initialize();
            var entityType = new EdmEntityType();
            var mappingContext = new MappingContext(modelConfiguration, new ConventionsConfiguration(), model);

            new NavigationPropertyMapper(new TypeMapper(mappingContext))
                .Map(new MockPropertyInfo(typeof(NavigationPropertyMapperTests[]), "Nav"), entityType,
                    () => new EntityTypeConfiguration(typeof(object)));

            Assert.Equal(0, model.Namespaces.Single().AssociationTypes.Count);
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:13,代码来源:NavigationPropertyMapperTests.cs


示例15: Apply_is_noop_when_unknown_dependent

        public void Apply_is_noop_when_unknown_dependent()
        {
            var model = new EdmModel().Initialize();
            var associationType = new EdmAssociationType().Initialize();
            var navigationProperty = new EdmNavigationProperty { Association = associationType };
            var foreignKeyAnnotation = new ForeignKeyAttribute("AId");
            navigationProperty.Annotations.SetClrAttributes(new[] { foreignKeyAnnotation });

            ((IEdmConvention<EdmNavigationProperty>)new ForeignKeyNavigationPropertyAttributeConvention())
                .Apply(navigationProperty, model);

            Assert.Null(associationType.Constraint);
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:13,代码来源:ForeignKeyAnnotationConventionTests.cs


示例16: Configure_should_configure_entity_set_name

        public void Configure_should_configure_entity_set_name()
        {
            var model = new EdmModel().Initialize();
            var entityType = new EdmEntityType { Name = "E" };
            var entitySet = model.AddEntitySet("ESet", entityType);

            var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object)) { EntitySetName = "MySet" };

            entityTypeConfiguration.Configure(entityType, model);

            Assert.Equal("MySet", entitySet.Name);
            Assert.Same(entityTypeConfiguration, entitySet.GetConfiguration());
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:13,代码来源:EntityTypeConfigurationTests.cs


示例17: GenerateEntityTypes

        private void GenerateEntityTypes(EdmModel model, DbDatabaseMapping databaseMapping)
        {
            //Contract.Requires(model != null);
            //Contract.Requires(databaseMapping != null);

            foreach (var entityType in model.GetEntityTypes())
            {
                if (!entityType.IsAbstract)
                {
                    new EntityTypeMappingGenerator(_providerManifest).
                        Generate(entityType, databaseMapping);
                }
            }
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:14,代码来源:DatabaseMappingGenerator.cs


示例18: MapEntityType_should_not_bring_in_base_class_by_default

        public void MapEntityType_should_not_bring_in_base_class_by_default()
        {
            var model = new EdmModel().Initialize();
            var typeMapper = new TypeMapper(new MappingContext(new ModelConfiguration(), new ConventionsConfiguration(), model));
            var mockType = new MockType("Bar").BaseType(new MockType("Foo"));

            var entityType = typeMapper.MapEntityType(mockType);

            Assert.NotNull(entityType);
            Assert.Null(entityType.BaseType);
            Assert.Equal(1, model.Namespaces.Single().EntityTypes.Count);
            Assert.Equal(1, model.Containers.Single().EntitySets.Count);
            Assert.Equal("Bar", model.GetEntitySet(entityType).Name);
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:14,代码来源:TypeMapperTests.cs


示例19: MappingContext

        public MappingContext(
            ModelConfiguration modelConfiguration,
            ConventionsConfiguration conventionsConfiguration,
            EdmModel model)
        {
            //Contract.Requires(modelConfiguration != null);
            //Contract.Requires(conventionsConfiguration != null);
            //Contract.Requires(model != null);

            _modelConfiguration = modelConfiguration;
            _conventionsConfiguration = conventionsConfiguration;
            _model = model;
            _attributeProvider = new AttributeProvider();
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:14,代码来源:MappingContext.cs


示例20: ApplyModel_should_run_targeted_model_conventions

        public void ApplyModel_should_run_targeted_model_conventions()
        {
            var model = new EdmModel().Initialize();
            var entityType = model.AddEntityType("E");
            var mockConvention = new Mock<IEdmConvention<EdmEntityType>>();
            var conventionsConfiguration = new ConventionsConfiguration(new IConvention[]
                {
                    mockConvention.Object
                });

            conventionsConfiguration.ApplyModel(model);

            mockConvention.Verify(c => c.Apply(entityType, model), Times.AtMostOnce());
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:14,代码来源:ConventionsConfigurationTests.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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