Exemplo n.º 1
0
 public void ParseSimpleOrderBy()
 {
     var model = new ODataModelBuilder().Add_Customer_EntityType().Add_Customers_EntitySet().GetServiceModel();
     var serviceBaseUri = new Uri("http://server/service/");
     var queryUri = new Uri(serviceBaseUri, "Customers?$orderby=Name");
     var semanticTree = SemanticTree.ParseUri(queryUri, serviceBaseUri, model);
     var orderByNode = semanticTree.Query as OrderByQueryNode;
     Assert.NotNull(orderByNode);
     Assert.Equal(QueryNodeKind.PropertyAccess, orderByNode.Expression.Kind);
     var propertyAccess = orderByNode.Expression as PropertyAccessQueryNode;
     Assert.NotNull(propertyAccess);
     var customerEntityType = model.FindDeclaredType(typeof(Customer).FullName) as IEdmEntityType;
     var nameProperty = customerEntityType.Properties().Single(p => p.Name == "Name");
     Assert.Equal(nameProperty, propertyAccess.Property);
 }
Exemplo n.º 2
0
        public void ParseSimpleOrderBy()
        {
            var model          = new ODataModelBuilder().Add_Customer_EntityType().Add_Customers_EntitySet().GetServiceModel();
            var serviceBaseUri = new Uri("http://server/service/");
            var queryUri       = new Uri(serviceBaseUri, "Customers?$orderby=Name");
            var semanticTree   = SemanticTree.ParseUri(queryUri, serviceBaseUri, model);
            var orderByNode    = semanticTree.Query as OrderByQueryNode;

            Assert.NotNull(orderByNode);
            Assert.Equal(QueryNodeKind.PropertyAccess, orderByNode.Expression.Kind);
            var propertyAccess = orderByNode.Expression as PropertyAccessQueryNode;

            Assert.NotNull(propertyAccess);
            var customerEntityType = model.FindDeclaredType(typeof(Customer).FullName) as IEdmEntityType;
            var nameProperty       = customerEntityType.Properties().Single(p => p.Name == "Name");

            Assert.Equal(nameProperty, propertyAccess.Property);
        }