/// <summary> /// Given a property name, if the associated type reference is strucutred, then this returns /// the property of the structured type. Otherwise, it returns null. /// </summary> /// <param name="parentReference">The parent type to be used to find binding options.</param> /// <param name="propertyName">The string designated the property name to be bound.</param> /// <param name="resolver">Resolver for uri parser.</param> /// <returns>The property associated with string and parent type.</returns> internal static IEdmProperty BindProperty(IEdmTypeReference parentReference, string propertyName, ODataUriResolver resolver = null) { if (resolver == null) { resolver = ODataUriResolver.Default; } IEdmStructuredTypeReference structuredParentType = parentReference == null ? null : parentReference.AsStructuredOrNull(); return structuredParentType == null ? null : resolver.ResolveProperty(structuredParentType.StructuredDefinition(), propertyName); }
private static bool TryBindAsDeclaredProperty(PathSegmentToken tokenIn, IEdmStructuredType edmType, ODataUriResolver resolver, out ODataPathSegment segment) { IEdmProperty prop = resolver.ResolveProperty(edmType, tokenIn.Identifier); if (prop == null) { segment = null; return false; } if (prop.PropertyKind == EdmPropertyKind.Structural) { segment = new PropertySegment((IEdmStructuralProperty)prop); return true; } if (prop.PropertyKind == EdmPropertyKind.Navigation) { segment = new NavigationPropertySegment((IEdmNavigationProperty)prop, null /*TODO: set*/); return true; } throw new ODataException(ODataErrorStrings.SelectExpandBinder_UnknownPropertyType(prop.Name)); }