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


C# IEdmEntityType.ODataFullName方法代码示例

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


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

示例1: ValidateEntry

        /// <summary>
        /// Validates the type of an entry in a top-level feed.
        /// </summary>
        /// <param name="entityType">The type of the entry.</param>
        internal void ValidateEntry(IEdmEntityType entityType)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(entityType != null, "entityType != null");

            // If we don't have a type, store the type of the first item.
            if (this.itemType == null)
            {
                this.itemType = entityType;
            }

            // Validate the expected and actual types.
            if (this.itemType.IsEquivalentTo(entityType))
            {
                return;
            }

            // If the types are not equivalent, make sure they have a common base type.
            IEdmType commonBaseType = EdmLibraryExtensions.GetCommonBaseType(this.itemType, entityType);
            if (commonBaseType == null)
            {
                throw new ODataException(Strings.FeedWithoutExpectedTypeValidator_IncompatibleTypes(entityType.ODataFullName(), this.itemType.ODataFullName()));
            }

            this.itemType = (IEdmEntityType)commonBaseType;
        }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:30,代码来源:FeedWithoutExpectedTypeValidator.cs

示例2: CheckEntityPropertyMapping

 internal static void CheckEntityPropertyMapping(ODataVersion version, IEdmEntityType entityType, IEdmModel model)
 {
     ODataEntityPropertyMappingCache epmCache = model.GetEpmCache(entityType);
     if ((epmCache != null) && (version < epmCache.EpmTargetTree.MinimumODataProtocolVersion))
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataVersionChecker_EpmVersionNotSupported(entityType.ODataFullName(), ODataUtils.ODataVersionToString(epmCache.EpmTargetTree.MinimumODataProtocolVersion), ODataUtils.ODataVersionToString(version)));
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:8,代码来源:ODataVersionChecker.cs

示例3: ValidateEntry

 internal void ValidateEntry(IEdmEntityType entityType)
 {
     if (this.itemType == null)
     {
         this.itemType = entityType;
     }
     if (!((IEdmType) this.itemType).IsEquivalentTo(((IEdmType) entityType)))
     {
         IEdmType commonBaseType = this.itemType.GetCommonBaseType(entityType);
         if (commonBaseType == null)
         {
             throw new ODataException(Microsoft.Data.OData.Strings.FeedWithoutExpectedTypeValidator_IncompatibleTypes(entityType.ODataFullName(), this.itemType.ODataFullName()));
         }
         this.itemType = (IEdmEntityType) commonBaseType;
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:16,代码来源:FeedWithoutExpectedTypeValidator.cs

示例4: BindKeyPropertyValue

        /// <summary>
        /// Binds a key property value.
        /// </summary>
        /// <param name="namedValue">The named value to bind.</param>
        /// <param name="collectionItemEntityType">The type of a single item in a collection to apply the key value to.</param>
        /// <returns>The bound key property value node.</returns>
        private KeyPropertyValue BindKeyPropertyValue(NamedValue namedValue, IEdmEntityType collectionItemEntityType)
        {
            // These are exception checks because the data comes directly from the potentially user specified tree.
            ExceptionUtils.CheckArgumentNotNull(namedValue, "namedValue");
            ExceptionUtils.CheckArgumentNotNull(namedValue.Value, "namedValue.Value");
            Debug.Assert(collectionItemEntityType != null, "collectionItemType != null");

            IEdmProperty keyProperty = null;
            if (namedValue.Name == null)
            {
                foreach (IEdmProperty p in collectionItemEntityType.Key())
                {
                    if (keyProperty == null)
                    {
                        keyProperty = p;
                    }
                    else
                    {
                        throw new ODataException(Strings.MetadataBinder_UnnamedKeyValueOnTypeWithMultipleKeyProperties(collectionItemEntityType.ODataFullName()));
                    }
                }
            }
            else
            {
                keyProperty = collectionItemEntityType.Key().Where(k => string.CompareOrdinal(k.Name, namedValue.Name) == 0).SingleOrDefault();

                if (keyProperty == null)
                {
                    throw new ODataException(Strings.MetadataBinder_PropertyNotDeclaredOrNotKeyInKeyValue(namedValue.Name, collectionItemEntityType.ODataFullName()));
                }
            }

            IEdmTypeReference keyPropertyType = keyProperty.Type;

            SingleValueQueryNode value = (SingleValueQueryNode)this.Bind(namedValue.Value);

            // TODO: Check that the value is of primitive type
            value = ConvertToType(value, keyPropertyType);

            Debug.Assert(keyProperty != null, "keyProperty != null");
            return new KeyPropertyValue()
            {
                KeyProperty = keyProperty,
                KeyValue = value
            };
        }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:52,代码来源:MetadataBinder.cs

示例5: LoadEpmAnnotations

        /// <summary>
        /// Loads the serializable EPM annotations on the given <paramref name="entityType"/> into their in-memory representation.
        /// </summary>
        /// <param name="model">The model the entity type belongs to.</param>
        /// <param name="entityType">The <see cref="IEdmEntityType"/> to load the EPM annotations for.</param>
        private static void LoadEpmAnnotations(IEdmModel model, IEdmEntityType entityType)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(entityType != null, "entityType != null");

            string entityTypeName = entityType.ODataFullName();
            ODataEntityPropertyMappingCollection mappings = new ODataEntityPropertyMappingCollection();

            // Load the annotations from the type (these are the mappings for properties not explicitly declared on this type)
            model.LoadEpmAnnotations(entityType, mappings, entityTypeName, null /*property*/);

            IEnumerable<IEdmProperty> declaredProperties = entityType.DeclaredProperties;
            if (declaredProperties != null)
            {
                foreach (IEdmProperty property in declaredProperties)
                {
                    // Load the EPM annotations for all properties independent of their kind in order to fail on invalid property kinds.
                    model.LoadEpmAnnotations(property, mappings, entityTypeName, property);
                }
            }

            // Set the new EPM annotation on the entity type only at the very end to not leave a 
            // inconsistent annotation if building it fails.
            model.SetAnnotationValue(entityType, mappings);
        }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:30,代码来源:EpmExtensionMethods.cs

示例6: ValidateNavigationPropertyDefined

        /// <summary>
        /// Validates that a navigation property with the specified name exists on a given entity type.
        /// The entity type can be null if no metadata is available.
        /// </summary>
        /// <param name="propertyName">The name of the property to validate.</param>
        /// <param name="owningEntityType">The owning entity type or null if no metadata is available.</param>
        /// <param name="messageReaderSettings">The message reader settings being used.</param>
        /// <returns>The <see cref="IEdmNavigationProperty"/> instance representing the navigation property with name <paramref name="propertyName"/>
        /// or null if no metadata is available.</returns>
        internal static IEdmNavigationProperty ValidateNavigationPropertyDefined(
            string propertyName,
            IEdmEntityType owningEntityType,
            ODataMessageReaderSettings messageReaderSettings)
        {
            Debug.Assert(!string.IsNullOrEmpty(propertyName), "!string.IsNullOrEmpty(propertyName)");
            Debug.Assert(messageReaderSettings != null, "messageReaderSettings != null");

            if (owningEntityType == null)
            {
                return null;
            }

            IEdmProperty property = ValidateLinkPropertyDefined(propertyName, owningEntityType, messageReaderSettings);
            if (property == null)
            {
                if (owningEntityType.IsOpen && !messageReaderSettings.ReportUndeclaredLinkProperties)
                {
                    // We don't support open navigation properties
                    throw new ODataException(Strings.ValidationUtils_OpenNavigationProperty(propertyName, owningEntityType.ODataFullName()));
                }
            }
            else if (property.PropertyKind != EdmPropertyKind.Navigation)
            {
                // The property must be a navigation property
                throw new ODataException(Strings.ValidationUtils_NavigationPropertyExpected(propertyName, owningEntityType.ODataFullName(), property.PropertyKind.ToString()));
            }

            return (IEdmNavigationProperty)property;
        }
开发者ID:rossjempson,项目名称:odata.net,代码行数:39,代码来源:ReaderValidationUtils.cs

示例7: ValidateEntryInExpandedLink

        /// <summary>
        /// Validates an entry in an expanded link to make sure the entity types match.
        /// </summary>
        /// <param name="entryEntityType">The <see cref="IEdmEntityType"/> of the entry.</param>
        /// <param name="parentNavigationPropertyType">The type of the parent navigation property.</param>
        internal static void ValidateEntryInExpandedLink(IEdmEntityType entryEntityType, IEdmType parentNavigationPropertyType)
        {
            DebugUtils.CheckNoExternalCallers();

            if (parentNavigationPropertyType == null)
            {
                return;
            }

            Debug.Assert(entryEntityType != null, "If we have a parent navigation property type we should also have an entry type.");

            bool navPropIsCollection = parentNavigationPropertyType.TypeKind == EdmTypeKind.Collection;
            IEdmEntityType parentNavigationPropertyEntityType = (IEdmEntityType)(navPropIsCollection
                ? ((IEdmCollectionType)parentNavigationPropertyType).ElementType.Definition
                : parentNavigationPropertyType);

            // Make sure the entity types are compatible
            if (!parentNavigationPropertyEntityType.IsAssignableFrom(entryEntityType))
            {
                throw new ODataException(Strings.WriterValidationUtils_EntryTypeInExpandedLinkNotCompatibleWithNavigationPropertyType(entryEntityType.ODataFullName(), parentNavigationPropertyEntityType.ODataFullName()));
            }
        }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:27,代码来源:WriterValidationUtils.cs

示例8: CheckEntityPropertyMapping

        /// <summary>
        /// Check whether the EPM on the specified entity type is supported in the specified version.
        /// </summary>
        /// <param name="version">The version to check.</param>
        /// <param name="entityType">The entity type to check.</param>
        /// <param name="model">The model containing annotations for the entity type.</param>
        internal static void CheckEntityPropertyMapping(ODataVersion version, IEdmEntityType entityType, IEdmModel model)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(entityType != null, "entityType != null");
            Debug.Assert(model != null, "model != null");

            ODataEntityPropertyMappingCache epmCache = model.GetEpmCache(entityType);
            if (epmCache != null)
            {
                Debug.Assert(epmCache.EpmTargetTree != null, "If the EPM annotation is present the EPM tree must already be initialized.");
                if (version < epmCache.EpmTargetTree.MinimumODataProtocolVersion)
                {
                    throw new ODataException(
                        Strings.ODataVersionChecker_EpmVersionNotSupported(
                            entityType.ODataFullName(),
                            ODataUtils.ODataVersionToString(epmCache.EpmTargetTree.MinimumODataProtocolVersion),
                            ODataUtils.ODataVersionToString(version)));
                }
            }
        }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:26,代码来源:ODataVersionChecker.cs

示例9: TryBindKeyPropertyValue

        /// <summary>
        /// Binds a key property value.
        /// </summary>
        /// <param name="namedValue">The named value to bind.</param>
        /// <param name="collectionItemEntityType">The type of a single item in a collection to apply the key value to.</param>
        /// <param name="keys">Dictionary of alias to keys.</param>
        /// <param name="keyPropertyValue">The bound key property value node.</param>
        /// <returns>The bound key property value node.</returns>
        private bool TryBindKeyPropertyValue(NamedValue namedValue, IEdmEntityType collectionItemEntityType, IDictionary<string, IEdmProperty> keys, out KeyPropertyValue keyPropertyValue)
        {
            // These are exception checks because the data comes directly from the potentially user specified tree.
            ExceptionUtils.CheckArgumentNotNull(namedValue, "namedValue");
            ExceptionUtils.CheckArgumentNotNull(namedValue.Value, "namedValue.Value");
            Debug.Assert(collectionItemEntityType != null, "collectionItemType != null");

            IEdmProperty keyProperty = null;
            if (namedValue.Name == null)
            {
                foreach (IEdmProperty p in keys.Values)
                {
                    if (keyProperty == null)
                    {
                        keyProperty = p;
                    }
                    else
                    {
                        throw new ODataException(ODataErrorStrings.MetadataBinder_UnnamedKeyValueOnTypeWithMultipleKeyProperties(collectionItemEntityType.ODataFullName()));
                    }
                }
            }
            else
            {
                keyProperty = keys.SingleOrDefault(k => string.CompareOrdinal(k.Key, namedValue.Name) == 0).Value;

                if (keyProperty == null)
                {
                    keyPropertyValue = null;
                    return false;
                }
            }

            IEdmTypeReference keyPropertyType = keyProperty.Type;

            SingleValueNode value = (SingleValueNode)this.keyValueBindMethod(namedValue.Value);

            // TODO: Check that the value is of primitive type
            Debug.Assert(keyPropertyType.IsODataPrimitiveTypeKind(), "The key's type must be primitive.");
            value = MetadataBindingUtils.ConvertToTypeIfNeeded(value, keyPropertyType);

            Debug.Assert(keyProperty != null, "keyProperty != null");
            keyPropertyValue = new KeyPropertyValue()
            {
                KeyProperty = keyProperty,
                KeyValue = value
            };

            return true;
        }
开发者ID:rossjempson,项目名称:odata.net,代码行数:58,代码来源:KeyBinder.cs

示例10: ValidateEntryMetadata

 internal static void ValidateEntryMetadata(ODataEntry entry, IEdmEntityType entityType, IEdmModel model, bool validateMediaResource)
 {
     if ((entityType != null) && validateMediaResource)
     {
         bool flag = model.HasDefaultStream(entityType);
         if (entry.MediaResource == null)
         {
             if (flag)
             {
                 throw new ODataException(Microsoft.Data.OData.Strings.ValidationUtils_EntryWithoutMediaResourceAndMLEType(entityType.ODataFullName()));
             }
         }
         else if (!flag)
         {
             throw new ODataException(Microsoft.Data.OData.Strings.ValidationUtils_EntryWithMediaResourceAndNonMLEType(entityType.ODataFullName()));
         }
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:18,代码来源:ValidationUtils.cs

示例11: ValidateEntryInExpandedLink

 internal static void ValidateEntryInExpandedLink(IEdmEntityType entryEntityType, IEdmType parentNavigationPropertyType)
 {
     if (parentNavigationPropertyType != null)
     {
         IEdmEntityType baseType = (parentNavigationPropertyType.TypeKind == EdmTypeKind.Collection) ? ((IEdmEntityType) ((IEdmCollectionType) parentNavigationPropertyType).ElementType.Definition) : ((IEdmEntityType) parentNavigationPropertyType);
         if (!baseType.IsAssignableFrom(entryEntityType))
         {
             throw new ODataException(Microsoft.Data.OData.Strings.WriterValidationUtils_EntryTypeInExpandedLinkNotCompatibleWithNavigationPropertyType(entryEntityType.ODataFullName(), baseType.ODataFullName()));
         }
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:11,代码来源:WriterValidationUtils.cs

示例12: ValidateNavigationPropertyDefined

 internal static IEdmProperty ValidateNavigationPropertyDefined(string propertyName, IEdmEntityType owningEntityType)
 {
     if (owningEntityType == null)
     {
         return null;
     }
     IEdmProperty property = ValidatePropertyDefined(propertyName, owningEntityType);
     if (property == null)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ValidationUtils_OpenNavigationProperty(propertyName, owningEntityType.ODataFullName()));
     }
     if (property.PropertyKind != EdmPropertyKind.Navigation)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ValidationUtils_NavigationPropertyExpected(propertyName, owningEntityType.ODataFullName(), property.PropertyKind.ToString()));
     }
     return property;
 }
开发者ID:nickchal,项目名称:pash,代码行数:17,代码来源:WriterValidationUtils.cs

示例13: LoadEpmAnnotations

 private static void LoadEpmAnnotations(IEdmModel model, IEdmEntityType entityType)
 {
     string typeName = entityType.ODataFullName();
     ODataEntityPropertyMappingCollection mappings = new ODataEntityPropertyMappingCollection();
     model.LoadEpmAnnotations(entityType, mappings, typeName, null);
     IEnumerable<IEdmProperty> declaredProperties = entityType.DeclaredProperties;
     if (declaredProperties != null)
     {
         foreach (IEdmProperty property in declaredProperties)
         {
             model.LoadEpmAnnotations(property, mappings, typeName, property);
         }
     }
     model.SetAnnotationValue<ODataEntityPropertyMappingCollection>(entityType, mappings);
 }
开发者ID:nickchal,项目名称:pash,代码行数:15,代码来源:EpmExtensionMethods.cs

示例14: ValidateNavigationPropertyDefined

        /// <summary>
        /// Validates that a navigation property with the specified name exists on a given entity type.
        /// The entity type can be null if no metadata is available.
        /// </summary>
        /// <param name="propertyName">The name of the property to validate.</param>
        /// <param name="owningEntityType">The owning entity type or null if no metadata is available.</param>
        /// <returns>The <see cref="IEdmProperty"/> instance representing the navigation property with name <paramref name="propertyName"/>
        /// or null if no metadata is available.</returns>
        internal static IEdmNavigationProperty ValidateNavigationPropertyDefined(string propertyName, IEdmEntityType owningEntityType)
        {
            Debug.Assert(!string.IsNullOrEmpty(propertyName), "!string.IsNullOrEmpty(propertyName)");

            if (owningEntityType == null)
            {
                return null;
            }

            IEdmProperty property = ValidatePropertyDefined(propertyName, owningEntityType);
            if (property == null)
            {
                // We don't support open navigation properties
                Debug.Assert(owningEntityType.IsOpen, "We should have already failed on non-existing property on a closed type.");
                throw new ODataException(Strings.ValidationUtils_OpenNavigationProperty(propertyName, owningEntityType.ODataFullName()));
            }

            if (property.PropertyKind != EdmPropertyKind.Navigation)
            {
                // The property must be a navigation property
                throw new ODataException(Strings.ValidationUtils_NavigationPropertyExpected(propertyName, owningEntityType.ODataFullName(), property.PropertyKind.ToString()));
            }

            return (IEdmNavigationProperty)property;
        }
开发者ID:rossjempson,项目名称:odata.net,代码行数:33,代码来源:WriterValidationUtils.cs

示例15: ValidateEntryMetadataResource

        /// <summary>
        /// Validates that the specified <paramref name="entry"/> is a valid entry as per the specified type.
        /// </summary>
        /// <param name="entry">The entry to validate.</param>
        /// <param name="entityType">Optional entity type to validate the entry against.</param>
        /// <param name="model">Model containing the entity type.</param>
        /// <param name="validateMediaResource">true if the validation of the default MediaResource should be done; false otherwise.</param>
        /// <remarks>If the <paramref name="entityType"/> is available only entry-level tests are performed, properties and such are not validated.</remarks>
        internal static void ValidateEntryMetadataResource(ODataEntry entry, IEdmEntityType entityType, IEdmModel model, bool validateMediaResource)
        {
            Debug.Assert(entry != null, "entry != null");

            if (entityType != null)
            {
                Debug.Assert(model != null, "model != null");
                Debug.Assert(model.IsUserModel(), "model.IsUserModel()");

                if (validateMediaResource)
                {
                    if (entry.MediaResource == null)
                    {
                        if (entityType.HasStream)
                        {
                            throw new ODataException(Strings.ValidationUtils_EntryWithoutMediaResourceAndMLEType(entityType.ODataFullName()));
                        }
                    }
                    else
                    {
                        if (!entityType.HasStream)
                        {
                            throw new ODataException(Strings.ValidationUtils_EntryWithMediaResourceAndNonMLEType(entityType.ODataFullName()));
                        }
                    }
                }
            }
        }
开发者ID:rossjempson,项目名称:odata.net,代码行数:36,代码来源:ValidationUtils.cs


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