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


C# IEdmEntityType.FullName方法代码示例

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


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

示例1: CastPathSegment

        /// <summary>
        /// Initializes a new instance of the <see cref="CastPathSegment" /> class.
        /// </summary>
        /// <param name="castType">The type of the cast.</param>
        public CastPathSegment(IEdmEntityType castType)
        {
            if (castType == null)
            {
                throw Error.ArgumentNull("castType");
            }

            CastType = castType;
            CastTypeName = castType.FullName();
        }
开发者ID:akrisiun,项目名称:WebApi,代码行数:14,代码来源:CastPathSegment.cs

示例2: EntityTypeInfo

        internal EntityTypeInfo(IEdmModel edmModel, IEdmEntityType edmEntityType, ITypeResolver typeResolver)
        {
            Contract.Assert(edmModel != null);
            Contract.Assert(edmEntityType != null);
            Contract.Assert(typeResolver != null);

            _edmEntityType = edmEntityType;
            string edmTypeName = edmEntityType.FullName();
            _type = typeResolver.ResolveTypeFromName(edmTypeName);

            // Initialize DontSerializeProperties
            _dontSerializeProperties = _type.GetProperties().Where(p => p.GetCustomAttributes(typeof(IgnoreDataMemberAttribute), true).Length > 0).Select(p => p.Name).ToArray();

            //edmEntityType.DeclaredKey;
            //edmEntityType.BaseEntityType();
            var structuralProperties = new List<PropertyInfo>();
            foreach (var edmStructuralProperty in edmEntityType.StructuralProperties())
            {
                if (! _dontSerializeProperties.Contains(edmStructuralProperty.Name))
                {
                    structuralProperties.Add(_type.GetProperty(edmStructuralProperty.Name));
                }
            }

            // EF can pick up private properties (eg: those marked as navigational).  We omit them on spec.
            _structuralProperties = structuralProperties.Where(p => p != null).ToArray();

            var navigationProperties = new List<PropertyInfo>();
            var linkProperties = new List<PropertyInfo>();
            foreach (var edmNavigationProperty in edmEntityType.NavigationProperties())
            {
                if (! _dontSerializeProperties.Contains(edmNavigationProperty.Name))
                {
                    if (edmNavigationProperty.Type.IsCollection())
                    {
                        linkProperties.Add(_type.GetProperty(edmNavigationProperty.Name));
                    }
                    else
                    {
                        navigationProperties.Add(_type.GetProperty(edmNavigationProperty.Name));
                    }
                }
            }
            _navigationProperties = navigationProperties.Where(p => p != null).ToArray();
            _collectionProperties = linkProperties.Where(p => p != null).ToArray();

            // Reflect for ValidationAttributes on all properties
            var validationInfo = new List<PropertyValidationInfo>();
            InitValidationInfo(validationInfo, _structuralProperties, PropertyCategory.Structural);
            InitValidationInfo(validationInfo, _navigationProperties, PropertyCategory.Navigation);
            InitValidationInfo(validationInfo, _collectionProperties, PropertyCategory.Collection);
            _propertyValidationInfo = validationInfo.ToArray();
        }
开发者ID:entityrepository,项目名称:ODataClient,代码行数:53,代码来源:EntityTypeInfo.cs

示例3: ReadEntityType

        private void ReadEntityType(IEdmEntityType entityType)
        {
            if (IsIgnored(entityType)) return;
            var typeUri = GetUriMapping(entityType);
            var identifierPrefix = GetIdentifierPrefix(entityType);

            _typeUriMap[entityType.FullName()] = new TypeMapping
                {
                    Uri = typeUri,
                    IdentifierPrefix = identifierPrefix
                };
            foreach (IEdmProperty property in entityType.Properties())
            {
                ReadProperty(entityType, property);
            }
        }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:16,代码来源:SparqlMap.cs

示例4: AssertEntityTypeIsDerivedFrom

        /// <summary>
        /// Asserts that a given entity type is derived from the specified base entity type.
        /// </summary>
        /// <param name="derivedType">The derived entity type.</param>
        /// <param name="baseType">The base entity type.</param>
        public static void AssertEntityTypeIsDerivedFrom(IEdmEntityType derivedType, IEdmEntityType baseType)
        {
            ExceptionUtilities.CheckArgumentNotNull(derivedType, "derivedType");
            ExceptionUtilities.CheckArgumentNotNull(baseType, "baseType");

            if (derivedType == baseType)
            {
                return;
            }

            var entityType = derivedType.BaseEntityType();
            while (entityType != null)
            {
                if (entityType == baseType)
                {
                    return;
                }

                entityType = entityType.BaseEntityType();
            }

            ExceptionUtilities.Assert(false, "Expected entity type " + derivedType.FullName() + " to be derived from " + baseType.FullName());
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:28,代码来源:EdmModelUtils.cs

示例5: VerifyCanCreateODataReader

        /// <summary>
        /// Verifies that CreateEntryReader or CreateFeedReader or CreateDeltaReader can be called.
        /// </summary>
        /// <param name="navigationSource">The navigation source we are going to read entities for.</param>
        /// <param name="entityType">The expected entity type for the entry/entries to be read.</param>
        private void VerifyCanCreateODataReader(IEdmNavigationSource navigationSource, IEdmEntityType entityType)
        {
            Debug.Assert(navigationSource == null || entityType != null, "If an navigation source is specified, the entity type must be specified as well.");

            // We require metadata information for reading requests.
            if (!this.ReadingResponse)
            {
                this.VerifyUserModel();

                if (navigationSource == null)
                {
                    throw new ODataException(ODataErrorStrings.ODataJsonLightInputContext_NoEntitySetForRequest);
                }
            }

            // We only check that the base type of the entity set is assignable from the specified entity type.
            // If no entity set/entity type is specified in the API, we will read it from the context URI.
            IEdmEntityType entitySetElementType = this.EdmTypeResolver.GetElementType(navigationSource);
            if (navigationSource != null && entityType != null && !entityType.IsOrInheritsFrom(entitySetElementType))
            {
                throw new ODataException(ODataErrorStrings.ODataJsonLightInputContext_EntityTypeMustBeCompatibleWithEntitySetBaseType(entityType.FullName(), entitySetElementType.FullName(), navigationSource.FullNavigationSourceName()));
            }
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:28,代码来源:ODataJsonLightInputContext.cs

示例6: CreateTypeNameExpression

        // OData formatter requires the type name of the entity that is being written if the type has derived types.
        // Expression
        //      source is GrandChild ? "GrandChild" : ( source is Child ? "Child" : "Root" )
        // Notice that the order is important here. The most derived type must be the first to check.
        // If entity framework had a way to figure out the type name without selecting the whole object, we don't have to do this magic.
        internal static Expression CreateTypeNameExpression(Expression source, IEdmEntityType elementType, IEdmModel model)
        {
            IReadOnlyList<IEdmEntityType> derivedTypes = GetAllDerivedTypes(elementType, model);

            if (derivedTypes.Count == 0)
            {
                // no inheritance.
                return null;
            }
            else
            {
                Expression expression = Expression.Constant(elementType.FullName());
                for (int i = 0; i < derivedTypes.Count; i++)
                {
                    Type clrType = EdmLibHelpers.GetClrType(derivedTypes[i], model);
                    if (clrType == null)
                    {
                        throw new ODataException(Error.Format(SRResources.MappingDoesNotContainEntityType, derivedTypes[0].FullName()));
                    }

                    expression = Expression.Condition(
                                    test: Expression.TypeIs(source, clrType),
                                    ifTrue: Expression.Constant(derivedTypes[i].FullName()),
                                    ifFalse: expression);
                }

                return expression;
            }
        }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:34,代码来源:SelectExpandBinder.cs

示例7: GetIdentifierPrefix

 private string GetIdentifierPrefix(IEdmEntityType entityType)
 {
     if (entityType.BaseEntityType() != null)
     {
         return GetIdentifierPrefix(entityType.BaseEntityType());
     }
     TypeMapping existingMapping;
     if (_typeUriMap.TryGetValue(entityType.FullName(), out existingMapping))
     {
         return existingMapping.IdentifierPrefix;
     }
     var keyList = entityType.DeclaredKey.ToList();
     if (keyList.Count != 1)
     {
         // Ignore this entity
         // TODO: Log an error
         return null;
     }
     var identifierPrefix = GetStringAnnotationValue(keyList.First(), AnnotationsNamespace, "IdentifierPrefix");
     if (identifierPrefix == null)
     {
         // TODO: Log an error
     }
     return identifierPrefix;
 }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:25,代码来源:SparqlMap.cs

示例8: GetJsonPayload

        internal static string GetJsonPayload(IEdmEntityType entityType, object value)
        {
            Type valueType = value.GetType();
            StringBuilder sb = new StringBuilder();
            sb.Append("{");
            sb.Append(Environment.NewLine);
            sb.Append("\t");
            sb.Append("@odata.type: \"" + entityType.FullName() + "\",");
            var properties = entityType.StructuralProperties().ToList();
            for (int i = 0; i < properties.Count; i++)
            {
                sb.Append("\t");
                IEdmProperty property = properties[i];
                // Type propertyType = ((PrimitiveType)property.TypeUsage.EdmType).ClrEquivalentType;
                PropertyInfo propertyInfo = valueType.GetProperty(property.Name);
                Type propertyType = propertyInfo.PropertyType;
                propertyType = Nullable.GetUnderlyingType(propertyType) ?? propertyType;            
                object propertyValue = propertyInfo.GetValue(value, null);
                sb.Append(String.Format("{0}:{1}", properties[i].Name, PrimitiveToString(propertyValue, propertyType)));
                if (i != properties.Count - 1)
                {
                    sb.Append(",");
                }
                sb.Append(Environment.NewLine);
            }
            sb.Append("}");

            return sb.ToString();
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:29,代码来源:JsonValidator.cs

示例9: GetUriForProperty

 public string GetUriForProperty(IEdmEntityType entityType, string propertyName)
 {
     return GetUriForProperty(entityType.FullName(), propertyName);
 }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:4,代码来源:SparqlMap.cs

示例10: ReadProperty

        private void ReadProperty(IEdmEntityType entityType, IEdmProperty property)
        {
            string declaredPropertyName;
            string entityPropertyName = entityType.FullName() + "." + property.Name;
            if (property.DeclaringType is IEdmEntityType)
            {
                declaredPropertyName = (property.DeclaringType as IEdmEntityType).FullName() + "." + property.Name;
            }
            else
            {
                declaredPropertyName = entityPropertyName;
            }

            PropertyMapping mapping;
            if (_propertyUriMap.TryGetValue(declaredPropertyName, out mapping))
            {
                _propertyUriMap[entityPropertyName] = mapping;
            }
            else
            {
                mapping = new PropertyMapping
                    {
                        Uri = GetUriMapping(property),
                        IsInverse = GetBooleanAnnotationValue(property, AnnotationsNamespace, "IsInverse", false),
                        IdentifierPrefix = GetStringAnnotationValue(property, AnnotationsNamespace, "IdentifierPrefix")
                    };
                // If the property maps to the resource identifier, do not record a property URI 
                if (!String.IsNullOrEmpty(mapping.IdentifierPrefix))
                {
                    mapping.Uri = null;
                }

                _propertyUriMap[entityPropertyName] = mapping;
                if (!declaredPropertyName.Equals(entityPropertyName))
                {
                    _propertyUriMap[declaredPropertyName] = mapping;
                }
            }
        }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:39,代码来源:SparqlMap.cs

示例11: CreateNavigationPropertiesForStockEntity

        private void CreateNavigationPropertiesForStockEntity(IEdmEntityType edmType, IEdmModel edmModel, EdmModel stockModel)
        {
            var stockType = (EdmEntityType)stockModel.FindType(edmType.FullName());

            foreach (var edmNavigation in edmType.DeclaredNavigationProperties())
            {
                var stockToRoleType = (EdmEntityType)stockModel.FindType(edmNavigation.ToEntityType().FullName());

                if (stockType.FindProperty(edmNavigation.Name) == null)
                {
                    Func<IEnumerable<IEdmStructuralProperty>, IEnumerable<IEdmStructuralProperty>> createDependentProperties = (dependentProps) =>
                    {
                        if (dependentProps == null)
                        {
                            return null;
                        }

                        var stockDependentProperties = new List<IEdmStructuralProperty>();
                        foreach (var dependentProperty in dependentProps)
                        {
                            var stockDepProp = edmNavigation.DependentProperties() != null ? stockType.FindProperty(dependentProperty.Name) : stockToRoleType.FindProperty(dependentProperty.Name);
                            stockDependentProperties.Add((IEdmStructuralProperty)stockDepProp);
                        }

                        return stockDependentProperties;
                    };

                    Func<IEdmReferentialConstraint, IEdmEntityType, IEnumerable<IEdmStructuralProperty>> createPrincipalProperties = (refConstraint, principalType) =>
                    {
                        if (refConstraint == null)
                        {
                            return null;
                        }

                        return refConstraint.PropertyPairs.Select(p => (IEdmStructuralProperty)principalType.FindProperty(p.PrincipalProperty.Name));
                    };

                    var propertyInfo = new EdmNavigationPropertyInfo()
                        {
                            Name = edmNavigation.Name,
                            Target = stockToRoleType,
                            TargetMultiplicity = edmNavigation.TargetMultiplicity(),
                            DependentProperties = createDependentProperties(edmNavigation.DependentProperties()),
                            PrincipalProperties = createPrincipalProperties(edmNavigation.ReferentialConstraint, stockToRoleType),
                            ContainsTarget = edmNavigation.ContainsTarget,
                            OnDelete = edmNavigation.OnDelete
                        };

                    bool bidirectional = edmNavigation.Partner != null && edmNavigation.ToEntityType().FindProperty(edmNavigation.Partner.Name) != null;
                    if (bidirectional)
                    {
                        var partnerInfo = new EdmNavigationPropertyInfo()
                        {
                            Name = edmNavigation.Partner.Name,
                            TargetMultiplicity = edmNavigation.Partner.TargetMultiplicity(), 
                            DependentProperties = createDependentProperties(edmNavigation.Partner.DependentProperties()),
                            PrincipalProperties = createPrincipalProperties(edmNavigation.Partner.ReferentialConstraint, stockType),
                            ContainsTarget = edmNavigation.Partner.ContainsTarget, 
                            OnDelete = edmNavigation.Partner.OnDelete
                        };

                        stockType.AddBidirectionalNavigation(propertyInfo, partnerInfo);
                    }
                    else
                    {
                        stockType.AddUnidirectionalNavigation(propertyInfo);
                    }
                }
            }
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:70,代码来源:EdmToStockModelConverter.cs

示例12: FillStockContentsForEntityWithoutNavigation

        private void FillStockContentsForEntityWithoutNavigation(IEdmEntityType edmType, IEdmModel edmModel, EdmModel stockModel)
        {
            var stockType = (EdmEntityType)stockModel.FindType(edmType.FullName());
            this.SetImmediateAnnotations(edmType, stockType, edmModel, stockModel);

            foreach (var edmProperty in edmType.DeclaredStructuralProperties())
            {
                ConvertToStockStructuralProperty((IEdmStructuralProperty)edmProperty, edmModel, stockModel);
            }

            if (edmType.DeclaredKey != null)
            {
                stockType.AddKeys(edmType.DeclaredKey.Select(n => stockType.FindProperty(n.Name) as IEdmStructuralProperty).ToArray());
            }
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:15,代码来源:EdmToStockModelConverter.cs

示例13: ConstructStockEntityTypeInModel

        private EdmEntityType ConstructStockEntityTypeInModel(IEdmEntityType entityType, EdmModel stockModel, Dictionary<string, EdmEntityType> stockEntityTypes)
        {
            EdmEntityType stockType;
            string fullName = entityType.FullName();
            if (!stockEntityTypes.TryGetValue(fullName, out stockType))
            {
                stockType = new EdmEntityType(
                    entityType.Namespace,
                    entityType.Name,
                    entityType.BaseType != null ? this.ConstructStockEntityTypeInModel((IEdmEntityType)entityType.BaseType, stockModel, stockEntityTypes) : null,
                    entityType.IsAbstract,
                    entityType.IsOpen);

                // TODO: IsBad, Documentation
                stockModel.AddElement(stockType);
                stockEntityTypes.Add(fullName, stockType);
            }

            return stockType;
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:20,代码来源:EdmToStockModelConverter.cs

示例14: UnresolvedNavigationPropertyPath

 public UnresolvedNavigationPropertyPath(IEdmEntityType startingType, string path, EdmLocation location)
     : base(startingType, path, new[] { new EdmError(location, EdmErrorCode.BadUnresolvedNavigationPropertyPath, Edm.Strings.Bad_UnresolvedNavigationPropertyPath(path, startingType.FullName())) })
 {
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:4,代码来源:UnresolvedNavigationPropertyPath.cs

示例15: GetKeyProperties

        /// <summary>
        /// Get key value pair array for specifc odata entry using specifc entity type
        /// </summary>
        /// <param name="entry">The entry instance.</param>
        /// <param name="serializationInfo">The serialization info of the entry for writing without model.</param>
        /// <param name="actualEntityType">The edm entity type of the entry</param>
        /// <returns>Key value pair array</returns>
        internal static KeyValuePair<string, object>[] GetKeyProperties(
            ODataEntry entry,
            ODataFeedAndEntrySerializationInfo serializationInfo,
            IEdmEntityType actualEntityType)
        {
            KeyValuePair<string, object>[] keyProperties = null;
            string actualEntityTypeName = null;

            if (serializationInfo != null)
            {
                if (String.IsNullOrEmpty(entry.TypeName))
                {
                    throw new ODataException(OData.Core.Strings.ODataFeedAndEntryTypeContext_ODataEntryTypeNameMissing);
                }

                actualEntityTypeName = entry.TypeName;
                keyProperties = ODataEntryMetadataContextWithoutModel.GetPropertiesBySerializationInfoPropertyKind(entry, ODataPropertyKind.Key, actualEntityTypeName);
            }
            else
            {
                actualEntityTypeName = actualEntityType.FullName();

                IEnumerable<IEdmStructuralProperty> edmKeyProperties = actualEntityType.Key();
                if (edmKeyProperties != null)
                {
                    keyProperties = edmKeyProperties.Select(p => new KeyValuePair<string, object>(p.Name, GetPrimitivePropertyClrValue(entry, p.Name, actualEntityTypeName, /*isKeyProperty*/false))).ToArray();
                }
            }

            ValidateEntityTypeHasKeyProperties(keyProperties, actualEntityTypeName);
            return keyProperties;
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:39,代码来源:ODataEntryMetadataContext.cs


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