/// <summary> /// Gets the target entity set for the given operation import. /// </summary> /// <param name="operationImport">The operation import.</param> /// <param name="sourceEntitySet">The source entity set.</param> /// <param name="model">The model.</param> /// <returns>The target entity set of the operation import or null if it could not be determined.</returns> internal static IEdmEntitySetBase GetTargetEntitySet(this IEdmOperationImport operationImport, IEdmEntitySetBase sourceEntitySet, IEdmModel model) { IEdmEntitySetBase targetEntitySet; if (operationImport.TryGetStaticEntitySet(model, out targetEntitySet)) { return(targetEntitySet); } if (sourceEntitySet == null) { return(null); } if (operationImport.Operation.IsBound && operationImport.Operation.Parameters.Any()) { IEdmOperationParameter parameter; Dictionary <IEdmNavigationProperty, IEdmPathExpression> path; IEnumerable <EdmError> errors; if (operationImport.TryGetRelativeEntitySetPath(model, out parameter, out path, out errors)) { IEdmEntitySetBase currentEntitySet = sourceEntitySet; foreach (var navigation in path) { currentEntitySet = currentEntitySet.FindNavigationTarget(navigation.Key, navigation.Value) as IEdmEntitySetBase; if (currentEntitySet is IEdmUnknownEntitySet) { return(currentEntitySet); } } return(currentEntitySet); } else { if (errors.Any( e => e.ErrorCode == EdmErrorCode.InvalidPathFirstPathParameterNotMatchingFirstParameterName)) { throw ExceptionUtil.CreateSyntaxError(); } } } return(null); }
/// <summary> /// Gets the target entity set for the given operation import. /// </summary> /// <param name="operationImport">The operation import.</param> /// <param name="sourceEntitySet">The source entity set.</param> /// <param name="model">The model.</param> /// <returns>The target entity set of the operation import or null if it could not be determined.</returns> internal static IEdmEntitySetBase GetTargetEntitySet(this IEdmOperationImport operationImport, IEdmEntitySetBase sourceEntitySet, IEdmModel model) { IEdmEntitySet targetEntitySet; if (operationImport.TryGetStaticEntitySet(out targetEntitySet)) { return(targetEntitySet); } if (sourceEntitySet == null) { return(null); } if (operationImport.Operation.IsBound && operationImport.Operation.Parameters.Any()) { IEdmOperationParameter parameter; IEnumerable <IEdmNavigationProperty> path; IEnumerable <EdmError> errors; if (operationImport.TryGetRelativeEntitySetPath(model, out parameter, out path, out errors)) { IEdmEntitySetBase currentEntitySet = sourceEntitySet; foreach (var navigation in path) { currentEntitySet = currentEntitySet.FindNavigationTarget(navigation) as IEdmEntitySetBase; if (currentEntitySet == null || currentEntitySet is IEdmUnknownEntitySet) { return(currentEntitySet); } } return(currentEntitySet); } else { bool foundSyntaxError = !errors.Any(e => e.ErrorCode == EdmErrorCode.InvalidPathFirstPathParameterNotMatchingFirstParameterName); ExceptionUtil.ThrowSyntaxErrorIfNotValid(foundSyntaxError); } } return(null); }