/// <summary> /// Parses an <paramref name="orderBy "/> clause, binding /// the text into semantic nodes using the provided model. /// </summary> /// <param name="orderBy">String representation of the orderby expression.</param> /// <param name="configuration">The configuration used for binding.</param> /// <param name="odataPathInfo">The path info from Uri path.</param> /// <returns>An <see cref="OrderByClause"/> representing the metadata bound orderby expression.</returns> private OrderByClause ParseOrderByImplementation(string orderBy, ODataUriParserConfiguration configuration, ODataPathInfo odataPathInfo) { ExceptionUtils.CheckArgumentNotNull(configuration, "configuration"); ExceptionUtils.CheckArgumentNotNull(configuration.Model, "model"); ExceptionUtils.CheckArgumentNotNull(orderBy, "orderBy"); // Get the syntactic representation of the orderby expression UriQueryExpressionParser expressionParser = new UriQueryExpressionParser(configuration.Settings.OrderByLimit, configuration.EnableCaseInsensitiveUriFunctionIdentifier); var orderByQueryTokens = expressionParser.ParseOrderBy(orderBy); // Bind it to metadata BindingState state = CreateBindingState(configuration, odataPathInfo); MetadataBinder binder = new MetadataBinder(state); OrderByBinder orderByBinder = new OrderByBinder(binder.Bind); OrderByClause orderByClause = orderByBinder.BindOrderBy(state, orderByQueryTokens); return(orderByClause); }
private BindingState CreateBindingState(ODataUriParserConfiguration configuration, ODataPathInfo odataPathInfo) { BindingState state = new BindingState(configuration, odataPathInfo.Segments.ToList()); state.ImplicitRangeVariable = NodeFactory.CreateImplicitRangeVariable(odataPathInfo.TargetEdmType.ToTypeReference(), odataPathInfo.TargetNavigationSource); state.RangeVariables.Push(state.ImplicitRangeVariable); state.ResourcePathNavigationSource = odataPathInfo.TargetNavigationSource; if (applyClause != null) { state.AggregatedPropertyNames = applyClause.GetLastAggregatedPropertyNames(); if (applyClause.Transformations.Any(x => x.Kind == TransformationNodeKind.GroupBy || x.Kind == TransformationNodeKind.Aggregate)) { state.IsCollapsed = true; } } if (computeClause != null) { var computedProperties = new HashSet <EndPathToken>(computeClause.ComputedItems.Select(i => new EndPathToken(i.Alias, null))); if (state.AggregatedPropertyNames == null) { state.AggregatedPropertyNames = computedProperties; } else { state.AggregatedPropertyNames.UnionWith(computedProperties); } } return(state); }
/// <summary> /// Parses an <paramref name="apply"/> clause, binding /// the text into a metadata-bound or dynamic properties to be applied using the provided model. /// </summary> /// <param name="apply">String representation of the apply expression.</param> /// <param name="configuration">The configuration used for binding.</param> /// <param name="odataPathInfo">The path info from Uri path.</param> /// <returns>A <see cref="ApplyClause"/> representing the metadata bound apply expression.</returns> private static ApplyClause ParseApplyImplementation(string apply, ODataUriParserConfiguration configuration, ODataPathInfo odataPathInfo) { ExceptionUtils.CheckArgumentNotNull(configuration, "configuration"); ExceptionUtils.CheckArgumentNotNull(apply, "apply"); // Get the syntactic representation of the apply expression UriQueryExpressionParser expressionParser = new UriQueryExpressionParser(configuration.Settings.FilterLimit, configuration.EnableCaseInsensitiveUriFunctionIdentifier); var applyTokens = expressionParser.ParseApply(apply); // Bind it to metadata BindingState state = new BindingState(configuration, odataPathInfo.Segments.ToList()); state.ImplicitRangeVariable = NodeFactory.CreateImplicitRangeVariable(odataPathInfo.TargetEdmType.ToTypeReference(), odataPathInfo.TargetNavigationSource); state.RangeVariables.Push(state.ImplicitRangeVariable); MetadataBinder binder = new MetadataBinder(state); ApplyBinder applyBinder = new ApplyBinder(binder.Bind, state, configuration, odataPathInfo); ApplyClause boundNode = applyBinder.BindApply(applyTokens); return(boundNode); }
/// <summary> /// Parses the <paramref name="select"/> and <paramref name="expand"/> clauses, binding /// the text into a metadata-bound list of properties to be selected using the provided model. /// </summary> /// <param name="select">String representation of the select expression from the URI.</param> /// <param name="expand">String representation of the expand expression from the URI.</param> /// <param name="configuration">The configuration used for binding.</param> /// <param name="odataPathInfo">The path info from Uri path.</param> /// <returns>A <see cref="SelectExpandClause"/> representing the metadata bound select and expand expression.</returns> private SelectExpandClause ParseSelectAndExpandImplementation(string select, string expand, ODataUriParserConfiguration configuration, ODataPathInfo odataPathInfo) { ExceptionUtils.CheckArgumentNotNull(configuration, "configuration"); ExceptionUtils.CheckArgumentNotNull(configuration.Model, "model"); ExpandToken expandTree; SelectToken selectTree; // syntactic pass , pass in the expand parent entity type name, in case expand option contains star, will get all the parent entity navigation properties (both declared and dynamical). SelectExpandSyntacticParser.Parse(select, expand, odataPathInfo.TargetStructuredType, configuration, out expandTree, out selectTree); // semantic pass BindingState state = CreateBindingState(configuration, odataPathInfo); return(SelectExpandSemanticBinder.Bind(odataPathInfo, expandTree, selectTree, configuration, state)); }
/// <summary> /// Parses a <paramref name="filter"/> clause, binding /// the text into semantic nodes using the provided model. /// </summary> /// <param name="filter">String representation of the filter expression.</param> /// <param name="configuration">The configuration used for binding.</param> /// <param name="odataPathInfo">The path info from Uri path.</param> /// <returns>A <see cref="FilterClause"/> representing the metadata bound filter expression.</returns> private FilterClause ParseFilterImplementation(string filter, ODataUriParserConfiguration configuration, ODataPathInfo odataPathInfo) { ExceptionUtils.CheckArgumentNotNull(configuration, "configuration"); ExceptionUtils.CheckArgumentNotNull(odataPathInfo, "odataPathInfo"); ExceptionUtils.CheckArgumentNotNull(filter, "filter"); // Get the syntactic representation of the filter expression UriQueryExpressionParser expressionParser = new UriQueryExpressionParser(configuration.Settings.FilterLimit, configuration.EnableCaseInsensitiveUriFunctionIdentifier); QueryToken filterToken = expressionParser.ParseFilter(filter); // Bind it to metadata BindingState state = CreateBindingState(configuration, odataPathInfo); MetadataBinder binder = new MetadataBinder(state); FilterBinder filterBinder = new FilterBinder(binder.Bind, state); FilterClause boundNode = filterBinder.BindFilter(filterToken); return(boundNode); }
/// <summary> /// Parses an <paramref name="orderBy "/> clause, binding /// the text into semantic nodes using the provided model. /// </summary> /// <param name="orderBy">String representation of the orderby expression.</param> /// <param name="configuration">The configuration used for binding.</param> /// <param name="odataPathInfo">The path info from Uri path.</param> /// <returns>An <see cref="OrderByClause"/> representing the metadata bound orderby expression.</returns> private OrderByClause ParseOrderByImplementation(string orderBy, ODataUriParserConfiguration configuration, ODataPathInfo odataPathInfo) { ExceptionUtils.CheckArgumentNotNull(configuration, "configuration"); ExceptionUtils.CheckArgumentNotNull(configuration.Model, "model"); ExceptionUtils.CheckArgumentNotNull(orderBy, "orderBy"); // Get the syntactic representation of the orderby expression UriQueryExpressionParser expressionParser = new UriQueryExpressionParser(configuration.Settings.OrderByLimit, configuration.EnableCaseInsensitiveUriFunctionIdentifier); var orderByQueryTokens = expressionParser.ParseOrderBy(orderBy); // Bind it to metadata BindingState state = new BindingState(configuration, odataPathInfo.Segments.ToList()); state.ImplicitRangeVariable = NodeFactory.CreateImplicitRangeVariable(odataPathInfo.TargetEdmType.ToTypeReference(), odataPathInfo.TargetNavigationSource); state.RangeVariables.Push(state.ImplicitRangeVariable); if (applyClause != null) { state.AggregatedPropertyNames = applyClause.GetLastAggregatedPropertyNames(); } MetadataBinder binder = new MetadataBinder(state); OrderByBinder orderByBinder = new OrderByBinder(binder.Bind); OrderByClause orderByClause = orderByBinder.BindOrderBy(state, orderByQueryTokens); return(orderByClause); }
/// <summary> /// Parses a <paramref name="filter"/> clause, binding /// the text into semantic nodes using the provided model. /// </summary> /// <param name="filter">String representation of the filter expression.</param> /// <param name="configuration">The configuration used for binding.</param> /// <param name="odataPathInfo">The path info from Uri path.</param> /// <returns>A <see cref="FilterClause"/> representing the metadata bound filter expression.</returns> private FilterClause ParseFilterImplementation(string filter, ODataUriParserConfiguration configuration, ODataPathInfo odataPathInfo) { ExceptionUtils.CheckArgumentNotNull(configuration, "configuration"); ExceptionUtils.CheckArgumentNotNull(odataPathInfo, "odataPathInfo"); ExceptionUtils.CheckArgumentNotNull(filter, "filter"); // Get the syntactic representation of the filter expression UriQueryExpressionParser expressionParser = new UriQueryExpressionParser(configuration.Settings.FilterLimit, configuration.EnableCaseInsensitiveUriFunctionIdentifier); QueryToken filterToken = expressionParser.ParseFilter(filter); // Bind it to metadata BindingState state = new BindingState(configuration, odataPathInfo.Segments.ToList()); state.ImplicitRangeVariable = NodeFactory.CreateImplicitRangeVariable(odataPathInfo.TargetEdmType.ToTypeReference(), odataPathInfo.TargetNavigationSource); state.RangeVariables.Push(state.ImplicitRangeVariable); if (applyClause != null) { state.AggregatedPropertyNames = applyClause.GetLastAggregatedPropertyNames(); } MetadataBinder binder = new MetadataBinder(state); FilterBinder filterBinder = new FilterBinder(binder.Bind, state); FilterClause boundNode = filterBinder.BindFilter(filterToken); return(boundNode); }
/// <summary> /// Parses the <paramref name="compute"/> clause, binding /// the text into a metadata-bound list of computations using the provided model. /// </summary> /// <param name="compute">String representation of the compute expression from the URI.</param> /// <param name="configuration">The configuration used for binding.</param> /// <param name="odataPathInfo">The path info from Uri path.</param> /// <returns>A <see cref="ComputeClause"/> representing the metadata bound compute expression.</returns> private ComputeClause ParseComputeImplementation(string compute, ODataUriParserConfiguration configuration, ODataPathInfo odataPathInfo) { ExceptionUtils.CheckArgumentNotNull(configuration, "configuration"); ExceptionUtils.CheckArgumentNotNull(compute, "compute"); // Get the syntactic representation of the apply expression UriQueryExpressionParser expressionParser = new UriQueryExpressionParser(configuration.Settings.FilterLimit, configuration.EnableCaseInsensitiveUriFunctionIdentifier); ComputeToken computeToken = expressionParser.ParseCompute(compute); // Bind it to metadata BindingState state = CreateBindingState(configuration, odataPathInfo); MetadataBinder binder = new MetadataBinder(state); ComputeBinder computeBinder = new ComputeBinder(binder.Bind); ComputeClause boundNode = computeBinder.BindCompute(computeToken); return(boundNode); }
/// <summary> /// Parses the <paramref name="compute"/> clause, binding /// the text into a metadata-bound list of compuations using the provided model. /// </summary> /// <param name="compute">String representation of the compute expression from the URI.</param> /// <param name="configuration">The configuration used for binding.</param> /// <param name="odataPathInfo">The path info from Uri path.</param> /// <returns>A <see cref="ComputeClause"/> representing the metadata bound compute expression.</returns> private static ComputeClause ParseComputeImplementation(string compute, ODataUriParserConfiguration configuration, ODataPathInfo odataPathInfo) { ExceptionUtils.CheckArgumentNotNull(configuration, "configuration"); ExceptionUtils.CheckArgumentNotNull(compute, "compute"); // Get the syntactic representation of the apply expression UriQueryExpressionParser expressionParser = new UriQueryExpressionParser(configuration.Settings.FilterLimit, configuration.EnableCaseInsensitiveUriFunctionIdentifier); ComputeToken computeToken = expressionParser.ParseCompute(compute); // Bind it to metadata BindingState state = new BindingState(configuration); state.ImplicitRangeVariable = NodeFactory.CreateImplicitRangeVariable(odataPathInfo.TargetEdmType.ToTypeReference(), odataPathInfo.TargetNavigationSource); state.RangeVariables.Push(state.ImplicitRangeVariable); MetadataBinder binder = new MetadataBinder(state); ComputeBinder computeBinder = new ComputeBinder(binder.Bind); ComputeClause boundNode = computeBinder.BindCompute(computeToken); return(boundNode); }