/// <summary>
        /// Parses the <paramref name="queryUri"/> and binds the query to the metadata provided
        /// then returns a new instance of <see cref="QueryDescriptorQueryNode"/>
        /// describing the query specified by the uri.
        /// </summary>
        /// <param name="queryUri">The absolute URI which holds the query to parse. This must be a path relative to the <paramref name="serviceBaseUri"/>.</param>
        /// <param name="serviceBaseUri">The base URI of the service.</param>
        /// <param name="model">The model to use for binding.</param>
        /// <param name="maxDepth">The maximum depth of any single query part. Security setting to guard against DoS attacks causing stack overflows and such.</param>
        /// <returns>A new instance of <see cref="QueryDescriptorQueryNode"/> which represents the query specified in the <paramref name="queryUri"/>.</returns>
        public static QueryDescriptorQueryNode ParseUri(Uri queryUri, Uri serviceBaseUri, IEdmModel model, int maxDepth)
        {
            ExceptionUtils.CheckArgumentNotNull(model, "model");

            QueryDescriptorQueryToken queryDescriptorQueryToken = QueryDescriptorQueryToken.ParseUri(queryUri, serviceBaseUri, maxDepth);
            MetadataBinder metadataBinder = new MetadataBinder(model);
            return metadataBinder.BindQuery(queryDescriptorQueryToken);
        }
Esempio n. 2
0
 public void ParseThenBind()
 {
     var            serviceBaseUri = new Uri("http://server/service/");
     var            queryUri       = new Uri(serviceBaseUri, "Customers(1)");
     var            syntacticTree  = SyntacticTree.ParseUri(queryUri, serviceBaseUri);
     var            model          = new ODataModelBuilder().Add_Customer_EntityType().Add_Customers_EntitySet().GetServiceModel();
     MetadataBinder binder         = new MetadataBinder(model);
     var            semanticTree   = binder.BindQuery(syntacticTree);
 }
        /// <summary>
        /// Parses the <paramref name="queryUri"/> and binds the query to the metadata provided
        /// then returns a new instance of <see cref="QueryDescriptorQueryNode"/>
        /// describing the query specified by the uri.
        /// </summary>
        /// <param name="queryUri">The absolute URI which holds the query to parse. This must be a path relative to the <paramref name="serviceBaseUri"/>.</param>
        /// <param name="serviceBaseUri">The base URI of the service.</param>
        /// <param name="metadataProvider">The metadata provider to use for binding.</param>
        /// <param name="maxDepth">The maximum depth of any single query part. Security setting to guard against DoS attacks causing stack overflows and such.</param>
        /// <returns>A new instance of <see cref="QueryDescriptorQueryNode"/> which represents the query specified in the <paramref name="queryUri"/>.</returns>
        public static QueryDescriptorQueryNode ParseUri(Uri queryUri, Uri serviceBaseUri, IDataServiceMetadataProvider metadataProvider, int maxDepth)
        {
            ExceptionUtils.CheckArgumentNotNull(metadataProvider, "metadataProvider");

            QueryDescriptorQueryToken queryDescriptorQueryToken = QueryDescriptorQueryToken.ParseUri(queryUri, serviceBaseUri, maxDepth);
            MetadataBinder            metadataBinder            = new MetadataBinder(metadataProvider);

            return(metadataBinder.BindQuery(queryDescriptorQueryToken));
        }
Esempio n. 4
0
 public void ParseThenBind()
 {
     var serviceBaseUri = new Uri("http://server/service/");
     var queryUri = new Uri(serviceBaseUri, "Customers(1)");
     var syntacticTree = SyntacticTree.ParseUri(queryUri, serviceBaseUri);
     var model = new ODataModelBuilder().Add_Customer_EntityType().Add_Customers_EntitySet().GetServiceModel();
     MetadataBinder binder = new MetadataBinder(model);
     var semanticTree = binder.BindQuery(syntacticTree);
 }
Esempio n. 5
0
        public void BindExtensionTest()
        {
            var metadata = QueryTestMetadata.BuildTestMetadata(this.PrimitiveTypeResolver, this.UntypedDataServiceProviderFactory);

            MetadataBinder binder = new MetadataBinder(metadata);
            SyntacticTree  syntax = new SyntacticTree(new TestExtensionQueryToken(), null, null, null, null, null, null, null, null, null);

            this.Assert.ExpectedException <ODataException>(
                () => binder.BindQuery(syntax),
                "An unsupported extension query token was found.",
                "BindExtensionTest");
        }