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


C# IProperty.GetMaxLength方法代码示例

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


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

示例1: GetPrimitiveTypeReference

        private static IEdmPrimitiveTypeReference GetPrimitiveTypeReference(
            IProperty efProperty)
        {
            var kind = EdmPrimitiveTypeKind.None;
            var propertyType = efProperty.ClrType;
            if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(System.Nullable<>))
            {
                propertyType = propertyType.GetGenericArguments()[0];
            }

            if (!s_primitiveTypeKindMap.TryGetValue(propertyType, out kind))
            {
                return null;
            }
            switch (kind)
            {
                default:
                    return EdmCoreModel.Instance.GetPrimitive(
                        kind, efProperty.IsNullable);
                case EdmPrimitiveTypeKind.Binary:
                    return EdmCoreModel.Instance.GetBinary(
                        efProperty.GetMaxLength() < 0, efProperty.GetMaxLength(),
                        efProperty.IsNullable);
                case EdmPrimitiveTypeKind.Decimal:
                    // TODO GitHubIssue#57: Complete EF7 to EDM model mapping
                    //return EdmCoreModel.Instance.GetDecimal(
                    //    efProperty.Precision, efProperty.Scale,
                    //    efProperty.Nullable);
                    return EdmCoreModel.Instance.GetDecimal(efProperty.IsNullable);
                case EdmPrimitiveTypeKind.String:
                    // TODO GitHubIssue#57: Complete EF7 to EDM model mapping
                    return EdmCoreModel.Instance.GetString(
                        efProperty.GetMaxLength() < 0, efProperty.GetMaxLength(),
                        null, efProperty.IsNullable);
                case EdmPrimitiveTypeKind.DateTimeOffset:
                case EdmPrimitiveTypeKind.Duration:
                    // TODO GitHubIssue#57: Complete EF7 to EDM model mapping
                    //return EdmCoreModel.Instance.GetTemporal(
                    //    kind, efProperty.Precision, efProperty.Nullable);
                    return EdmCoreModel.Instance.GetTemporal(kind, efProperty.IsNullable);
            }
        }
开发者ID:adestis-mh,项目名称:RESTier,代码行数:42,代码来源:ModelProducer.cs

示例2: GetPrimitiveTypeReference

        private static IEdmPrimitiveTypeReference GetPrimitiveTypeReference(
            IProperty efProperty)
        {
            var kind = EdmPrimitiveTypeKind.None;
            var propertyType = TypeHelper.GetUnderlyingTypeOrSelf(efProperty.ClrType);

            if (!primitiveTypeKindMap.TryGetValue(propertyType, out kind))
            {
                return null;
            }

            if (TypeHelper.IsDateTime(propertyType))
            {
                RelationalPropertyAnnotations annotations = new RelationalPropertyAnnotations(efProperty, null);
                var columnType = annotations.ColumnType;

                if (string.Equals(columnType, "date", StringComparison.OrdinalIgnoreCase))
                {
                    kind = EdmPrimitiveTypeKind.Date;
                }
            }
            else if (TypeHelper.IsTimeSpan(propertyType))
            {
                RelationalPropertyAnnotations annotations = new RelationalPropertyAnnotations(efProperty, null);
                var columnType = annotations.ColumnType;

                if (string.Equals(columnType, "time", StringComparison.OrdinalIgnoreCase))
                {
                    kind = EdmPrimitiveTypeKind.TimeOfDay;
                }
            }

            switch (kind)
            {
                default:
                    return EdmCoreModel.Instance.GetPrimitive(kind, efProperty.IsNullable);
                case EdmPrimitiveTypeKind.Binary:
                    return EdmCoreModel.Instance.GetBinary(
                        efProperty.GetMaxLength() < 0,
                        efProperty.GetMaxLength(),
                        efProperty.IsNullable);
                case EdmPrimitiveTypeKind.Decimal:

                    // TODO GitHubIssue#57: Complete EF7 to EDM model mapping
                    ////return EdmCoreModel.Instance.GetDecimal(
                    ////    efProperty.Precision, efProperty.Scale,
                    ////    efProperty.Nullable);
                    return EdmCoreModel.Instance.GetDecimal(efProperty.IsNullable);
                case EdmPrimitiveTypeKind.String:
                    // TODO GitHubIssue#57: Complete EF7 to EDM model mapping
                    return EdmCoreModel.Instance.GetString(
                        efProperty.GetMaxLength() < 0,
                        efProperty.GetMaxLength(),
                        null,
                        efProperty.IsNullable);
                case EdmPrimitiveTypeKind.DateTimeOffset:
                case EdmPrimitiveTypeKind.Duration:

                    // TODO GitHubIssue#57: Complete EF7 to EDM model mapping
                    ////return EdmCoreModel.Instance.GetTemporal(
                    ////    kind, efProperty.Precision, efProperty.Nullable);
                    return EdmCoreModel.Instance.GetTemporal(kind, efProperty.IsNullable);
            }
        }
开发者ID:kosinsky,项目名称:RESTier,代码行数:64,代码来源:ModelProducer.cs

示例3: FindCustomMapping

 protected override RelationalTypeMapping FindCustomMapping(IProperty property, bool unicode = true)
     => property.ClrType == typeof(string) && property.GetMaxLength().HasValue
         ? new RelationalTypeMapping((unicode ? "nvarchar(" : "varchar(") + property.GetMaxLength() + ")", typeof(string))
         : base.FindCustomMapping(property, unicode);
开发者ID:ChuYuzhi,项目名称:EntityFramework,代码行数:4,代码来源:MigrationSqlGeneratorTest.cs

示例4: FindCustomMapping

 protected override RelationalTypeMapping FindCustomMapping(IProperty property)
     => property.ClrType == typeof(string) && property.GetMaxLength().HasValue
         ? new RelationalTypeMapping("nvarchar(" + property.GetMaxLength() + ")", typeof(string), dbType: null, unicode: true, size: property.GetMaxLength())
         : base.FindCustomMapping(property);
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:4,代码来源:MigrationSqlGeneratorTest.cs


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