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


C# EdmProperty.IsKey方法代码示例

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


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

示例1: Discover

        public IConfiguration Discover(EdmProperty property, DbModel model)
        {
            Debug.Assert(property != null, "property is null.");
            Debug.Assert(model != null, "model is null.");

            var columnProperty = model.GetColumn(property);

            if (property.IsKey() && _identityKeyTypes.Contains(property.PrimitiveType.PrimitiveTypeKind))
            {
                if (columnProperty.IsStoreGeneratedIdentity)
                {
                    // By convention
                    return null;
                }
            }
            else if (columnProperty.IsTimestamp())
            {
                // By convention
                return null;
            }
            else if (columnProperty.StoreGeneratedPattern == StoreGeneratedPattern.None)
            {
                // Doesn't apply
                return null;
            }

            return new DatabaseGeneratedConfiguration { StoreGeneratedPattern = columnProperty.StoreGeneratedPattern };
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:28,代码来源:DatabaseGeneratedDiscoverer.cs

示例2: Discover

        public override IConfiguration Discover(EdmProperty property, DbModel model)
        {
            Debug.Assert(property != null, "property is null.");
            Debug.Assert(model != null, "model is null.");

            if (!_lengthTypes.Contains(property.PrimitiveType.PrimitiveTypeKind))
            {
                // Doesn't apply
                return null;
            }

            if (property.IsMaxLength
                || !property.MaxLength.HasValue
                || (property.MaxLength.Value == 128 && property.IsKey()))
            {
                // By convention
                return null;
            }

            var configuration = property.PrimitiveType.PrimitiveTypeKind == PrimitiveTypeKind.String
                ? new MaxLengthStringConfiguration()
                : new MaxLengthConfiguration();
            configuration.MaxLength = property.MaxLength.Value;

            return configuration;
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:26,代码来源:MaxLengthDiscoverer.cs

示例3: Discover

        public IConfiguration Discover(EdmProperty property, DbModel model)
        {
            Debug.Assert(property != null, "property is null.");
            Debug.Assert(model != null, "model is null.");

            if (property.Nullable
                || property.PrimitiveType.ClrEquivalentType.IsValueType
                || property.IsKey()
                || model.GetColumn(property).IsTimestamp())
            {
                // By convention
                return null;
            }

            return new RequiredConfiguration();
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:16,代码来源:RequiredDiscoverer.cs


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