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

C# Edm.EdmProperty类代码示例

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

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



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

示例1: IsServerGenerated

 private static bool IsServerGenerated(EdmProperty property) {
     MetadataProperty generated;
     if (property.MetadataProperties.TryGetValue(StoreGeneratedMetadata, false, out generated)) {
         return "Identity" == (string)generated.Value || "Computed" == (string)generated.Value;
     }
     return false;
 }
开发者ID:duncansmart,项目名称:DynamicData.EFCodeFirstProvider,代码行数:7,代码来源:EFCodeFirstColumnProvider.cs


示例2: FunctionImportMappingComposable

        internal FunctionImportMappingComposable(
            EdmFunction functionImport,
            EdmFunction targetFunction,
            List<Tuple<StructuralType, List<StorageConditionPropertyMapping>, List<StoragePropertyMapping>>> structuralTypeMappings,
            EdmProperty[] targetFunctionKeys,
            StorageMappingItemCollection mappingItemCollection,
            string sourceLocation,
            LineInfo lineInfo) 
            : base(functionImport, targetFunction)
        {
            EntityUtil.CheckArgumentNull(mappingItemCollection, "mappingItemCollection");
            Debug.Assert(functionImport.IsComposableAttribute, "functionImport.IsComposableAttribute");
            Debug.Assert(targetFunction.IsComposableAttribute, "targetFunction.IsComposableAttribute");
            Debug.Assert(functionImport.EntitySet == null || structuralTypeMappings != null, "Function import returning entities must have structuralTypeMappings.");
            Debug.Assert(structuralTypeMappings == null || structuralTypeMappings.Count > 0, "Non-null structuralTypeMappings must not be empty.");
            EdmType resultType;
            Debug.Assert(
                structuralTypeMappings != null ||
                MetadataHelper.TryGetFunctionImportReturnType<EdmType>(functionImport, 0, out resultType) && TypeSemantics.IsScalarType(resultType),
                "Either type mappings should be specified or the function import should be Collection(Scalar).");
            Debug.Assert(functionImport.EntitySet == null || targetFunctionKeys != null, "Keys must be inferred for a function import returning entities.");
            Debug.Assert(targetFunctionKeys == null || targetFunctionKeys.Length > 0, "Keys must be null or non-empty.");

            m_mappingItemCollection = mappingItemCollection;
            // We will use these parameters to target s-space function calls in the generated command tree. 
            // Since enums don't exist in s-space we need to use the underlying type.
            m_commandParameters = functionImport.Parameters.Select(p => TypeHelpers.GetPrimitiveTypeUsageForScalar(p.TypeUsage).Parameter(p.Name)).ToArray();
            m_structuralTypeMappings = structuralTypeMappings;
            m_targetFunctionKeys = targetFunctionKeys;
            m_sourceLocation = sourceLocation;
            m_lineInfo = lineInfo;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:32,代码来源:FunctionImportMappingComposable.cs


示例3: GetStoreType

        public override string GetStoreType(EdmProperty property)
        {
            if (property.TypeUsage.EdmType.Name == "int")
                return "INTEGER";

            return base.GetStoreType(property);
        }
开发者ID:naster01,项目名称:chinook-database,代码行数:7,代码来源:SqliteStrategy.cs


示例4: GetGenerationOption

        public string GetGenerationOption(EdmProperty property, EntityType entity)
        {
            string result = "";
            bool isPk = entity.KeyMembers.Contains(property);
            MetadataProperty storeGeneratedPatternProperty = null;
            string storeGeneratedPatternPropertyValue = "None";

            if (property.MetadataProperties.TryGetValue(MetadataConstants.EDM_ANNOTATION_09_02 + ":StoreGeneratedPattern", false, out storeGeneratedPatternProperty))
                storeGeneratedPatternPropertyValue = storeGeneratedPatternProperty.Value.ToString();

            PrimitiveType edmType = (PrimitiveType)property.TypeUsage.EdmType;
            if (edmType == null && property.TypeUsage.EdmType is EnumType)
            {
                EnumType enumType = property.TypeUsage.EdmType as EnumType;
                edmType = enumType.UnderlyingType;
            }
            if (storeGeneratedPatternPropertyValue == "Computed")
            {
                result = ".HasDatabaseGeneratedOption(new Nullable<DatabaseGeneratedOption>(DatabaseGeneratedOption.Computed))";
            }
            else if ((edmType.ClrEquivalentType == typeof(int)) || (edmType.ClrEquivalentType == typeof(short)) || (edmType.ClrEquivalentType == typeof(long)))
            {
                if (isPk && (storeGeneratedPatternPropertyValue != "Identity"))
                    result = ".HasDatabaseGeneratedOption(new Nullable<DatabaseGeneratedOption>(DatabaseGeneratedOption.None))";
                else if ((!isPk || (entity.KeyMembers.Count > 1)) && (storeGeneratedPatternPropertyValue == "Identity"))
                    result = ".HasDatabaseGeneratedOption(new Nullable<DatabaseGeneratedOption>(DatabaseGeneratedOption.Identity))";
            }
            return result;
        }
开发者ID:jradxl,项目名称:Entity-Framework-Code-Generation-Tools-Experiments,代码行数:29,代码来源:EF5DbContextFluentMappingLibrary.cs


示例5: StorageModificationFunctionResultBinding

        internal StorageModificationFunctionResultBinding(string columnName, EdmProperty property)
        {
            //Contract.Requires(columnName != null);
            //Contract.Requires(property != null);

            ColumnName = columnName;
            Property = property;
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:8,代码来源:StorageModificationFunctionResultBinding.cs


示例6: FieldDescriptor

 /// <summary>
 /// Construct a new instance of the FieldDescriptor class that describes a property
 /// on items of the supplied type.
 /// </summary>
 /// <param name="itemType">Type of object whose property is described by this FieldDescriptor.</param>
 /// <param name="isReadOnly">
 /// <b>True</b> if property value on item can be modified; otherwise <b>false</b>.
 /// </param>
 /// <param name="property">
 /// EdmProperty that describes the property on the item.
 /// </param>
 internal FieldDescriptor(Type itemType, bool isReadOnly, EdmProperty property)
     : base(property.Name, null)
 {
     _itemType = itemType;
     _property = property;
     _isReadOnly = isReadOnly;
     _fieldType = DetermineClrType(_property.TypeUsage);
     System.Diagnostics.Debug.Assert(_fieldType != null, "FieldDescriptor's CLR type has unexpected value of null.");
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:20,代码来源:FieldDescriptor.cs


示例7: WriteCreateColumn

 public override string WriteCreateColumn(EdmProperty property, Version targetVersion)
 {
     var notnull = (property.Nullable ? "" : "NOT NULL");
     var identity = GetIdentity(property, targetVersion);
     return string.Format("{0} {1} {2} {3}",
                          FormatName(property.Name),
                          GetStoreType(property),
                          identity, notnull).Trim();
 }
开发者ID:naster01,项目名称:chinook-database,代码行数:9,代码来源:EffiProzStrategy.cs


示例8: StorageScalarPropertyMapping

 /// <summary>
 /// Construct a new Scalar EdmProperty mapping object
 /// </summary>
 /// <param name="member"></param>
 /// <param name="columnMember"></param>
 internal StorageScalarPropertyMapping(EdmProperty member, EdmProperty columnMember)
     : base(member) {
     Debug.Assert(columnMember != null);
     Debug.Assert(
         Helper.IsScalarType(member.TypeUsage.EdmType), 
         "StorageScalarPropertyMapping must only map primitive or enum types");
     Debug.Assert(Helper.IsPrimitiveType(columnMember.TypeUsage.EdmType), "StorageScalarPropertyMapping must only map primitive types");
     this.m_columnMember = columnMember;
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:14,代码来源:StorageScalarPropertyMapping.cs


示例9: DetermineIsForeignKeyComponent

        private bool DetermineIsForeignKeyComponent(EdmProperty property) {
            var navigationProperties = property.DeclaringType.Members.OfType<NavigationProperty>();

            // Look at all NavigationProperties (i.e. strongly-type relationship columns) of the table this column belong to and
            // see if there is a foreign key that matches this property
            // If this is a 1 to 0..1 relationship and we are processing the more primary side. i.e in the Student in Student-StudentDetail
            // and this is the primary key we don't want to check the relationship type since if there are no constraints we will treat the primary key as a foreign key.
            return navigationProperties.Any(n => EFCodeFirstAssociationProvider.GetDependentPropertyNames(n, !IsPrimaryKey /* checkRelationshipType */).Contains(property.Name));
        }
开发者ID:duncansmart,项目名称:DynamicData.EFCodeFirstProvider,代码行数:9,代码来源:EFCodeFirstColumnProvider.cs


示例10: StorageConditionPropertyMapping

 /// <summary>
 /// Construct a new condition Property mapping object
 /// </summary>
 /// <param name="cdmMember"></param>
 /// <param name="columnMember"></param>
 /// <param name="value"></param>
 /// <param name="isNull"></param>
 internal StorageConditionPropertyMapping(EdmProperty cdmMember, EdmProperty columnMember
     , object value, Nullable<bool> isNull) : base(cdmMember) {
     Debug.Assert((cdmMember != null) || (columnMember != null), "Both CDM and Column Members can not be specified for Condition Mapping");
     Debug.Assert((cdmMember == null) || (columnMember == null), "Either CDM or Column Members has to be specified for Condition Mapping");
     Debug.Assert((isNull.HasValue) || (value != null), "Both Value and IsNull can not be specified on Condition Mapping");
     Debug.Assert(!(isNull.HasValue) || (value == null), "Either Value or IsNull has to be specified on Condition Mapping");
     this.m_columnMember = columnMember;
     this.m_value = value;
     this.m_isNull = isNull;
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:17,代码来源:StorageConditionPropertyMapping.cs


示例11: StateManagerMemberMetadata

 internal StateManagerMemberMetadata(ObjectPropertyMapping memberMap, EdmProperty memberMetadata, bool isPartOfKey)
 {
     // if memberMap is null, then this is a shadowstate
     Debug.Assert(null != memberMap, "shadowstate not supported");
     Debug.Assert(null != memberMetadata, "CSpace should never be null");
     _clrProperty = memberMap.ClrProperty;
     _edmProperty = memberMetadata;
     _isPartOfKey = isPartOfKey;
     _isComplexType = (Helper.IsEntityType(_edmProperty.TypeUsage.EdmType) ||
                       Helper.IsComplexType(_edmProperty.TypeUsage.EdmType));
 }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:11,代码来源:StateManagerMemberMetadata.cs


示例12: GetStoreType

 public override string GetStoreType(EdmProperty property)
 {
     switch (property.TypeUsage.EdmType.Name)
     {
         case "datetime":
             return "DATE";
         case "nvarchar":
             return property.ToStoreType().Replace("nvarchar", "VARCHAR");
         default:
             return base.GetStoreType(property);
     }
 }
开发者ID:naster01,项目名称:chinook-database,代码行数:12,代码来源:Db2Strategy.cs


示例13: GenerateColumn

 static string GenerateColumn(EdmProperty property)
 {
     var column = new StringBuilder();
     column.Append(SqlGenerator.QuoteIdentifier(property.Name));
     column.Append(" ");
     column.Append(SqlGenerator.GetSqlPrimitiveType(property.TypeUsage));
     if (MetadataHelpers.IsStoreGeneratedIdentity(property))
     {
         column.Append(" GENERATED BY DEFAULT AS IDENTITY");
     }
     if (!property.Nullable)
     {
         column.Append(" NOT NULL");
     }
     return column.ToString();
 }
开发者ID:nodoubt223rd,项目名称:nuodb-dotnet,代码行数:16,代码来源:ScriptBuilder.cs


示例14: GetCorrespondingDependentProperty

        /// <summary>
        /// Given a property on the principal end of a referential constraint, returns the corresponding property on the dependent end.
        /// Requires: The association has a referential constraint, and the specified principalProperty is one of the properties on the principal end.
        /// </summary>
        public EdmProperty GetCorrespondingDependentProperty(NavigationProperty navProperty, EdmProperty principalProperty)
        {
            if (navProperty == null)
            {
                throw new ArgumentNullException("navProperty");
            }

            if (principalProperty == null)
            {
                throw new ArgumentNullException("principalProperty");
            }

            ReadOnlyMetadataCollection<EdmProperty> fromProperties = GetPrincipalProperties(navProperty);
            ReadOnlyMetadataCollection<EdmProperty> toProperties = GetDependentProperties(navProperty);
            return toProperties[fromProperties.IndexOf(principalProperty)];
        }
开发者ID:KCL5South,项目名称:KCLTextTemplating,代码行数:20,代码来源:MetadataTools.cs


示例15: AddPropertyMapping

 /// <summary>
 /// Add a mapping from the propertyRef (of the old type) to the 
 /// corresponding property in the new type.
 /// 
 /// NOTE: Only to be used by StructuredTypeInfo
 /// </summary>
 /// <param name="propertyRef"></param>
 /// <param name="newProperty"></param>
 internal void AddPropertyMapping(PropertyRef propertyRef, EdmProperty newProperty)
 {
     m_propertyMap[propertyRef] = newProperty;
     if (propertyRef is TypeIdPropertyRef)
     {
         m_typeIdProperty = newProperty;
     }
     else if (propertyRef is EntitySetIdPropertyRef)
     {
         m_entitySetIdProperty = newProperty;
     }
     else if (propertyRef is NullSentinelPropertyRef)
     {
         m_nullSentinelProperty = newProperty;
     }
 }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:24,代码来源:RootTypeInfo.cs


示例16: EntityDataSourceMemberPath

        internal EntityDataSourceMemberPath(MetadataWorkspace ocWorkspace, EntityDataSourceMemberPath parent, EdmProperty property, bool isLocallyInteresting)
        {
            EntityDataSourceUtil.CheckArgumentNull(ocWorkspace, "ocWorkspace");
            EntityDataSourceUtil.CheckArgumentNull(property, "property");
            
            this.property = property;
            this.parent = parent;
            this.isLocallyInteresting = isLocallyInteresting;
            this.clrType = EntityDataSourceUtil.GetMemberClrType(ocWorkspace, property);
            this.isKey = IsPropertyAKey(property);

            // retrieve PropertyInfo (with respect to parent CLR type)
            StructuralType parentType = property.DeclaringType;
            Type parentClrType = EntityDataSourceUtil.GetClrType(ocWorkspace, parentType);

            this.propertyInfo = EntityDataSourceUtil.GetPropertyInfo(parentClrType, this.property.Name);
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:17,代码来源:EntityDataSourceMemberPath.cs


示例17: CreateDisplayName

        private static string CreateDisplayName(EntityDataSourceReferenceGroup group, EdmProperty keyMember)
        {
            EntityDataSourceUtil.CheckArgumentNull(group, "group");
            EntityDataSourceUtil.CheckArgumentNull(keyMember, "keyMember");

            NavigationProperty navigationProperty;

            string result;

            if (EntityDataSourceUtil.TryGetCorrespondingNavigationProperty(group.End.CorrespondingAssociationEndMember, out navigationProperty))
            {
                result = navigationProperty.Name + "." + keyMember.Name;
            }
            else
            {
                // if there is no Navigation property, use the TargetTole and KeyMember name
                // TargetRole.KeyMember
                result = group.End.Name + "." + keyMember.Name;
            }

            return result;
        }
开发者ID:uQr,项目名称:referencesource,代码行数:22,代码来源:EntityDataSourceColumn.cs


示例18: IsPropertyAKey

 private bool IsPropertyAKey(EdmProperty property)
 {
     bool isKey = false;
     EntityType entityType = property.DeclaringType as EntityType;
     if (null != entityType)
     {
         isKey = entityType.KeyMembers.Contains(property);
     }
     return isKey;
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:10,代码来源:EntityDataSourceMemberPath.cs


示例19: GetFacetString

    private string GetFacetString(EdmProperty column)
    {
      StringBuilder sql = new StringBuilder();
      Facet facet;
      Facet fcDateTimePrecision = null;

      ReadOnlyMetadataCollection<Facet> facets = column.TypeUsage.Facets;

      if (column.TypeUsage.EdmType.BaseType.Name == "String")
      {
        // types tinytext, mediumtext, text & longtext don't have a length.
        if (!column.TypeUsage.EdmType.Name.EndsWith("text", StringComparison.OrdinalIgnoreCase))
        {
          if (facets.TryGetValue("MaxLength", true, out facet))
            sql.AppendFormat(" ({0})", facet.Value);
        }
      }
      else if (column.TypeUsage.EdmType.BaseType.Name == "Decimal")
      {
        Facet fcScale;
        Facet fcPrecision;
        if (facets.TryGetValue("Scale", true, out fcScale) && facets.TryGetValue("Precision", true, out fcPrecision))
        {
          // Enforce scale to a reasonable value.
          int scale = fcScale.Value == null ? 0 : ( int )( byte )fcScale.Value;
          if (scale == 0)
            scale = MySqlProviderManifest.DEFAULT_DECIMAL_SCALE;
          sql.AppendFormat("( {0}, {1} ) ", fcPrecision.Value, scale);
        }
      }
      else if (column.TypeUsage.EdmType.BaseType.Name == "DateTime")
      {
        if (serverVersion >= new Version(5, 6) && facets.TryGetValue("Precision", true, out fcDateTimePrecision))
        {        
           if (Convert.ToByte(fcDateTimePrecision.Value) >= 1)
              sql.AppendFormat("( {0} ) ", fcDateTimePrecision.Value);            
        }
      }
      

      if (facets.TryGetValue("Nullable", true, out facet) && (bool)facet.Value == false)
        sql.Append(" NOT NULL");

      if (facets.TryGetValue("StoreGeneratedPattern", true, out facet))
      {
        if (facet.Value.Equals(StoreGeneratedPattern.Identity))
        {

          if (column.TypeUsage.EdmType.BaseType.Name.StartsWith("Int"))
            sql.Append(" AUTO_INCREMENT UNIQUE");
          else if (column.TypeUsage.EdmType.BaseType.Name == "Guid")
            _guidIdentityColumns.Add(column.Name);
          else if (serverVersion >= new Version(5, 6) && column.TypeUsage.EdmType.BaseType.Name == "DateTime")
            sql.AppendFormat(" DEFAULT CURRENT_TIMESTAMP{0}", fcDateTimePrecision != null && Convert.ToByte(fcDateTimePrecision.Value) >= 1 ? "( " + fcDateTimePrecision.Value.ToString() + " )" : "");                              
          else
            throw new MySqlException("Invalid identity column type.");
        }      
      }
      return sql.ToString();
    }
开发者ID:luguandao,项目名称:MySql.Data,代码行数:60,代码来源:ProviderServices.cs


示例20: EntityDataSourceReferenceKeyColumn

        internal EntityDataSourceReferenceKeyColumn(MetadataWorkspace workspace, EntityDataSourceReferenceGroup group, EdmProperty keyMember, EntityDataSourceColumn dependent)
            : base(CreateDisplayName(group, keyMember), dependent)
        {
            EntityDataSourceUtil.CheckArgumentNull(group, "group");
            EntityDataSourceUtil.CheckArgumentNull(keyMember, "keyMember");
            Debug.Assert(EntityDataSourceUtil.IsScalar(keyMember.TypeUsage.EdmType), "Expected primitive or enum type for key members.");

            this.group = group;
            this.keyMember = keyMember;
            this.clrType = EntityDataSourceUtil.GetMemberClrType(workspace, keyMember);

            // if the association end is optional (0..1), make sure the CLR type
            // is also nullable
            if (this.group.End.CorrespondingAssociationEndMember.RelationshipMultiplicity == RelationshipMultiplicity.ZeroOrOne)
            {
                this.clrType = EntityDataSourceUtil.MakeNullable(clrType);
                this.isNullable = true;
            }
        }
开发者ID:uQr,项目名称:referencesource,代码行数:19,代码来源:EntityDataSourceColumn.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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