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

C# Edm.EdmProperty类代码示例

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

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



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

示例1: Apply_should_discover_for_self_reference

        public void Apply_should_discover_for_self_reference()
        {
            var associationType = new EdmAssociationType().Initialize();

            associationType.SourceEnd.EndKind = EdmAssociationEndKind.Optional;
            associationType.SourceEnd.EntityType = new EdmEntityType();

            associationType.TargetEnd.EndKind = EdmAssociationEndKind.Many;
            associationType.TargetEnd.EntityType = associationType.SourceEnd.EntityType;

            var pkProperty = new EdmProperty().AsPrimitive();
            associationType.SourceEnd.EntityType.DeclaredKeyProperties.Add(pkProperty);

            var fkProperty = new EdmProperty().AsPrimitive();
            associationType.TargetEnd.EntityType.DeclaredProperties.Add(fkProperty);
            associationType.TargetEnd.EntityType.AddNavigationProperty("Nav", associationType).ResultEnd = associationType.SourceEnd;
            associationType.TargetEnd.EntityType.AddNavigationProperty("Foos", associationType);

            // Foo.Id == Foo.NavId
            pkProperty.Name = "Id";
            fkProperty.Name = "NavId";

            ((IEdmConvention<EdmAssociationType>)new NavigationPropertyNameForeignKeyDiscoveryConvention())
                .Apply(associationType, new EdmModel().Initialize());

            Assert.NotNull(associationType.Constraint);
            Assert.Same(associationType.TargetEnd, associationType.Constraint.DependentEnd);
            Assert.Equal("NavId", associationType.Constraint.DependentProperties.Single().Name);
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:29,代码来源:NavigationPropertyNameForeignKeyDiscoveryConventionTests.cs


示例2: AsPrimitive_should_create_property_type_and_facets

        public void AsPrimitive_should_create_property_type_and_facets()
        {
            var property = new EdmProperty().AsPrimitive();

            Assert.NotNull(property.PropertyType);
            Assert.NotNull(property.PropertyType.PrimitiveTypeFacets);
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:7,代码来源:EdmPropertyExtensionsTests.cs


示例3: AsEnum_should_create_property_type

        public void AsEnum_should_create_property_type()
        {
            var property = new EdmProperty().AsEnum(new EdmEnumType());

            Assert.NotNull(property.PropertyType);
            Assert.True(property.PropertyType.IsEnumType);
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:7,代码来源:EdmPropertyExtensionsTests.cs


示例4: Apply_should_discover_composite_matching_foreign_keys

        public void Apply_should_discover_composite_matching_foreign_keys()
        {
            var associationType = CreateAssociationType();

            var pkProperty1 = new EdmProperty().AsPrimitive();
            var pkProperty2 = new EdmProperty().AsPrimitive();
            associationType.SourceEnd.EntityType.DeclaredKeyProperties.Add(pkProperty1);
            associationType.SourceEnd.EntityType.DeclaredKeyProperties.Add(pkProperty2);

            var fkProperty1 = new EdmProperty().AsPrimitive();
            var fkProperty2 = new EdmProperty().AsPrimitive();
            associationType.TargetEnd.EntityType.DeclaredProperties.Add(fkProperty1);
            associationType.TargetEnd.EntityType.DeclaredProperties.Add(fkProperty2);

            // Foo.PId1 == Bar.PId1 && Foo.PId2 == Bar.PId2
            pkProperty1.Name = "PId1";
            pkProperty2.Name = "PId2";
            fkProperty1.Name = "PId1";
            fkProperty2.Name = "PId2";

            ((IEdmConvention<EdmAssociationType>)new PrimaryKeyNameForeignKeyDiscoveryConvention())
                .Apply(associationType, new EdmModel().Initialize());

            Assert.NotNull(associationType.Constraint);
            Assert.Same(associationType.TargetEnd, associationType.Constraint.DependentEnd);
            Assert.Equal(2, associationType.Constraint.DependentProperties.Count());
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:27,代码来源:PrimaryKeyNameForeignKeyDiscoveryConventionTests.cs


示例5: Can_get_and_set_configuration_annotation

        public void Can_get_and_set_configuration_annotation()
        {
            var property = new EdmProperty();

            property.SetConfiguration(42);

            Assert.Equal(42, property.GetConfiguration());
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:8,代码来源:EdmPropertyExtensionsTests.cs


示例6: AsComplex_should_create_property_type

        public void AsComplex_should_create_property_type()
        {
            var property = new EdmProperty().AsComplex(new EdmComplexType());

            Assert.NotNull(property.PropertyType);
            Assert.True(property.PropertyType.IsComplexType);
            Assert.Equal(false, property.PropertyType.IsNullable);
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:8,代码来源:EdmPropertyExtensionsTests.cs


示例7: GetStoreGeneratedPattern_should_return_null_when_not_set

        public void GetStoreGeneratedPattern_should_return_null_when_not_set()
        {
            var property = new EdmProperty().AsPrimitive();

            var storeGeneratedPattern = property.GetStoreGeneratedPattern();

            Assert.Null(storeGeneratedPattern);
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:8,代码来源:EdmPropertyExtensionsTests.cs


示例8: MapPrimitiveOrComplexOrEnumProperty

        private EdmProperty MapPrimitiveOrComplexOrEnumProperty(
            PropertyInfo propertyInfo, Func<StructuralTypeConfiguration> structuralTypeConfiguration,
            bool discoverComplexTypes = false)
        {
            //Contract.Requires(propertyInfo != null);

            var property = propertyInfo.AsEdmPrimitiveProperty();

            if (property == null)
            {
                var propertyType = propertyInfo.PropertyType;
                var complexType = _typeMapper.MapComplexType(propertyType, discoverComplexTypes);

                if (complexType != null)
                {
                    property = new EdmProperty
                        {
                            Name = propertyInfo.Name
                        }.AsComplex(complexType);
                }
                else
                {
                    var isNullable = propertyType.TryUnwrapNullableType(out propertyType);

                    if (propertyType.IsEnum)
                    {
                        var enumType = _typeMapper.MapEnumType(propertyType);

                        if (enumType != null)
                        {
                            property = new EdmProperty
                                {
                                    Name = propertyInfo.Name,
                                }.AsEnum(enumType);
                            property.PropertyType.IsNullable = isNullable;
                        }
                    }
                }
            }

            if (property != null)
            {
                property.SetClrPropertyInfo(propertyInfo);

                new AttributeMapper(_typeMapper.MappingContext.AttributeProvider)
                    .Map(propertyInfo, property.Annotations);

                if (!property.PropertyType.IsComplexType)
                {
                    _typeMapper.MappingContext.ConventionsConfiguration.ApplyPropertyConfiguration(
                        propertyInfo, () => structuralTypeConfiguration().Property(new PropertyPath(propertyInfo)));
                }
            }

            return property;
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:56,代码来源:PropertyMapper.cs


示例9: Configure_should_update_model_dateTime_precision

        public void Configure_should_update_model_dateTime_precision()
        {
            var configuration = CreateConfiguration();
            configuration.Precision = 255;
            var property = new EdmProperty().AsPrimitive();

            configuration.Configure(property);

            Assert.Equal((byte)255, property.PropertyType.PrimitiveTypeFacets.Precision);
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:10,代码来源:DateTimePropertyConfigurationTests.cs


示例10: Configure_should_update_IsUnicode

        public void Configure_should_update_IsUnicode()
        {
            var configuration = CreateConfiguration();
            configuration.IsUnicode = true;
            var property = new EdmProperty().AsPrimitive();

            configuration.Configure(property);

            Assert.Equal(true, property.PropertyType.PrimitiveTypeFacets.IsUnicode);
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:10,代码来源:StringPropertyConfigurationTests.cs


示例11: SetStoreGeneratedPattern_should_create_annotation_and_add_to_property_facets

        public void SetStoreGeneratedPattern_should_create_annotation_and_add_to_property_facets()
        {
            var property = new EdmProperty().AsPrimitive();

            property.SetStoreGeneratedPattern(DbStoreGeneratedPattern.Computed);

            var storeGeneratedPattern = property.GetStoreGeneratedPattern();

            Assert.NotNull(storeGeneratedPattern);
            Assert.Equal(DbStoreGeneratedPattern.Computed, storeGeneratedPattern);
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:11,代码来源:EdmPropertyExtensionsTests.cs


示例12: Configure_should_update_model_decimal_scale_but_not_precision

        public void Configure_should_update_model_decimal_scale_but_not_precision()
        {
            var configuration = CreateConfiguration();
            configuration.Scale = 70;
            var property = new EdmProperty().AsPrimitive();

            configuration.Configure(property);

            Assert.Equal((byte)70, property.PropertyType.PrimitiveTypeFacets.Scale);
            Assert.Equal(null, property.PropertyType.PrimitiveTypeFacets.Precision);
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:11,代码来源:DecimalPropertyConfigurationTests.cs


示例13: Configure_should_update_MaxLength

        public void Configure_should_update_MaxLength()
        {
            var property = new EdmProperty().AsPrimitive();

            var configuration = CreateConfiguration();
            configuration.MaxLength = 1;

            configuration.Configure(property);

            Assert.Equal(1, property.PropertyType.PrimitiveTypeFacets.MaxLength);
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:11,代码来源:LengthPropertyConfigurationTests.cs


示例14: Configure_should_set_CSpace_configuration_annotation

        public void Configure_should_set_CSpace_configuration_annotation()
        {
            var configuration = CreateConfiguration();
            var property = new EdmProperty().AsPrimitive();

            Assert.Null(property.GetConfiguration());

            configuration.Configure(property);

            Assert.Same(configuration, property.GetConfiguration());
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:11,代码来源:PrimitivePropertyConfigurationTests.cs


示例15: SetStoreGeneratedPattern_should_update_existing_annotation

        public void SetStoreGeneratedPattern_should_update_existing_annotation()
        {
            var property = new EdmProperty().AsPrimitive();

            property.SetStoreGeneratedPattern(DbStoreGeneratedPattern.Computed);
            property.SetStoreGeneratedPattern(DbStoreGeneratedPattern.None);

            var storeGeneratedPattern = property.GetStoreGeneratedPattern();

            Assert.NotNull(storeGeneratedPattern);
            Assert.Equal(DbStoreGeneratedPattern.None, storeGeneratedPattern);
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:12,代码来源:EdmPropertyExtensionsTests.cs


示例16: Apply_should_set_correct_defaults_for_unconfigured_decimal

        public void Apply_should_set_correct_defaults_for_unconfigured_decimal()
        {
            var property = new EdmProperty().AsPrimitive();
            property.PropertyType.EdmType = EdmPrimitiveType.Decimal;

            ((IEdmConvention<EdmProperty>)new DecimalPropertyConvention())
                .Apply(property, new EdmModel());

            var primitiveTypeFacets = property.PropertyType.PrimitiveTypeFacets;

            Assert.Equal((byte)18, primitiveTypeFacets.Precision);
            Assert.Equal((byte)2, primitiveTypeFacets.Scale);
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:13,代码来源:DecimalPropertyConventionTests.cs


示例17: AddPrimitiveProperty

        public static EdmProperty AddPrimitiveProperty(this EdmComplexType complexType, string name)
        {
            //Contract.Requires(complexType != null);
            //Contract.Requires(complexType.Properties != null);
            //Contract.Requires(!string.IsNullOrWhiteSpace(name));

            var property = new EdmProperty().AsPrimitive();
            property.Name = name;

            complexType.DeclaredProperties.Add(property);

            return property;
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:13,代码来源:EdmComplexTypeExtensions.cs


示例18: Apply_should_set_correct_defaults_for_unconfigured_strings

        public void Apply_should_set_correct_defaults_for_unconfigured_strings()
        {
            var entityType = new EdmEntityType();
            var property = new EdmProperty().AsPrimitive();
            property.PropertyType.EdmType = EdmPrimitiveType.String;
            entityType.DeclaredProperties.Add(property);

            ((IEdmConvention<EdmEntityType>)new SqlCePropertyMaxLengthConvention())
                .Apply(entityType, CreateEdmModel());

            var primitiveTypeFacets = property.PropertyType.PrimitiveTypeFacets;

            Assert.Equal(4000, primitiveTypeFacets.MaxLength);
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:14,代码来源:SqlCePropertyMaxLengthConventionTests.cs


示例19: Apply_should_match_simple_short_key

        public void Apply_should_match_simple_short_key()
        {
            var entityType = new EdmEntityType();
            var property = new EdmProperty().AsPrimitive();
            property.PropertyType.EdmType = EdmPrimitiveType.Int16;
            entityType.DeclaredKeyProperties.Add(property);

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

            Assert.Equal(
                DbStoreGeneratedPattern.Identity,
                entityType.DeclaredKeyProperties.Single().GetStoreGeneratedPattern());
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:14,代码来源:StoreGeneratedIdentityKeyConventionTests.cs


示例20: Configure

        internal override void Configure(EdmProperty property)
        {
            if (IsRowVersion != null)
            {
                ColumnType = ColumnType ?? "rowversion";
                ConcurrencyMode = ConcurrencyMode ?? EdmConcurrencyMode.Fixed;
                DatabaseGeneratedOption
                    = DatabaseGeneratedOption
                      ?? ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Computed;
                IsNullable = IsNullable ?? false;
                MaxLength = MaxLength ?? 8;
            }

            base.Configure(property);
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:15,代码来源:BinaryPropertyConfiguration.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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