当前位置: 首页>>代码示例>>C#>>正文


C# ODataUriParser.ParseOrderBy方法代码示例

本文整理汇总了C#中Microsoft.OData.Core.UriParser.ODataUriParser.ParseOrderBy方法的典型用法代码示例。如果您正苦于以下问题:C# ODataUriParser.ParseOrderBy方法的具体用法?C# ODataUriParser.ParseOrderBy怎么用?C# ODataUriParser.ParseOrderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.OData.Core.UriParser.ODataUriParser的用法示例。


在下文中一共展示了ODataUriParser.ParseOrderBy方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: NoneQueryOptionShouldWork

 public void NoneQueryOptionShouldWork()
 {
     var uriParser = new ODataUriParser(HardCodedTestModel.TestModel, ServiceRoot, FullUri);
     var path = uriParser.ParsePath();
     path.Should().HaveCount(1);
     path.LastSegment.ShouldBeEntitySetSegment(HardCodedTestModel.GetPeopleSet());
     uriParser.ParseFilter().Should().BeNull();
     uriParser.ParseSelectAndExpand().Should().BeNull();
     uriParser.ParseOrderBy().Should().BeNull();
     uriParser.ParseTop().Should().Be(null);
     uriParser.ParseSkip().Should().Be(null);
     uriParser.ParseCount().Should().Be(null);
     uriParser.ParseSearch().Should().BeNull();
     uriParser.ParseSkipToken().Should().BeNull();
     uriParser.ParseDeltaToken().Should().BeNull();
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:16,代码来源:ODataUriParserTests.cs

示例2: TestCaseInsensitive

        private static void TestCaseInsensitive()
        {
            Console.WriteLine("TestCaseInsensitive");
            var parser = new ODataUriParser(
                extModel.Model,
                ServiceRoot,
                new Uri("http://demo/odata.svc/People(1)/Pets/TestNS.Fish?$orderby=Color"));

            var path = parser.ParsePath();
            var clause = parser.ParseOrderBy();
            Console.WriteLine(path.ToLogString());
            Console.WriteLine(clause.Expression.ToLogString());

            var parser2 = new ODataUriParser(
                extModel.Model,
                ServiceRoot,
                new Uri("http://demo/odata.svc/people(1)/pets/testns.fish?$ORDERBY=color"))
            {
                Resolver = new ODataUriResolver { EnableCaseInsensitive = true }
            };

            // Identical to path and clause
            var path2 = parser2.ParsePath();
            var clause2 = parser2.ParseOrderBy();
            Console.WriteLine(path2.ToLogString());
            Console.WriteLine(clause2.Expression.ToLogString());

            // Query option parser also supports custom resolver
            var parser3 = new ODataQueryOptionParser(
                extModel.Model,
                extModel.Fish,
                extModel.PetSet,
                new Dictionary<string, string>
                {
                    {"$orderby", "color"}
                })
            {
                Resolver = new ODataUriResolver { EnableCaseInsensitive = true }
            };
            var clause3 = parser3.ParseOrderBy();
            Console.WriteLine(clause3.Expression.ToLogString());
        }
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:42,代码来源:Program.cs

示例3: EmptyValueQueryOptionShouldWork

 public void EmptyValueQueryOptionShouldWork()
 {
     var uriParser = new ODataUriParser(HardCodedTestModel.TestModel, ServiceRoot, new Uri(FullUri, "?$filter=&$select=&$expand=&$orderby=&$top=&$skip=&$count=&$search=&$unknow=&$unknowvalue&$skiptoken=&$deltatoken="));
     var path = uriParser.ParsePath();
     path.Should().HaveCount(1);
     path.LastSegment.ShouldBeEntitySetSegment(HardCodedTestModel.GetPeopleSet());
     uriParser.ParseFilter().Should().BeNull();
     var results = uriParser.ParseSelectAndExpand();
     results.AllSelected.Should().BeTrue();
     results.SelectedItems.Should().HaveCount(0);
     uriParser.ParseOrderBy().Should().BeNull();
     Action action = () => uriParser.ParseTop();
     action.ShouldThrow<ODataException>().WithMessage(Strings.SyntacticTree_InvalidTopQueryOptionValue(""));
     action = () => uriParser.ParseSkip();
     action.ShouldThrow<ODataException>().WithMessage(Strings.SyntacticTree_InvalidSkipQueryOptionValue(""));
     action = () => uriParser.ParseCount();
     action.ShouldThrow<ODataException>().WithMessage(Strings.ODataUriParser_InvalidCount(""));
     action = () => uriParser.ParseSearch();
     action.ShouldThrow<ODataException>().WithMessage(Strings.UriQueryExpressionParser_ExpressionExpected(0, ""));
     uriParser.ParseSkipToken().Should().BeEmpty();
     uriParser.ParseDeltaToken().Should().BeEmpty();
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:22,代码来源:ODataUriParserTests.cs

示例4: ParseQueryOptionsShouldWork

 public void ParseQueryOptionsShouldWork()
 {
     var parser = new ODataUriParser(HardCodedTestModel.TestModel, new Uri("People?$filter=MyDog/Color eq 'Brown'&$select=ID&$expand=MyDog&$orderby=ID&$top=1&$skip=2&$count=true&$search=FA&$unknow=&$unknowvalue&$skiptoken=abc&$deltatoken=def", UriKind.Relative));
     parser.ParseSelectAndExpand().Should().NotBeNull();
     parser.ParseFilter().Should().NotBeNull();
     parser.ParseOrderBy().Should().NotBeNull();
     parser.ParseTop().Should().Be(1);
     parser.ParseSkip().Should().Be(2);
     parser.ParseCount().Should().Be(true);
     parser.ParseSearch().Should().NotBeNull();
     parser.ParseSkipToken().Should().Be("abc");
     parser.ParseDeltaToken().Should().Be("def");
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:13,代码来源:ODataUriParserTests.cs

示例5: OrderByLimitWithInterestingTreeStructures

 public void OrderByLimitWithInterestingTreeStructures()
 {
     ODataUriParser parser = new ODataUriParser(HardCodedTestModel.TestModel, ServiceRoot, new Uri("http://host/People?$orderby=MyDog/MyPeople/MyDog/MyPeople/MyPaintings asc")) { Settings = { OrderByLimit = 5 } };
     Action parseWithLimit = () => parser.ParseOrderBy();
     parseWithLimit.ShouldThrow<ODataException>().WithMessage(ODataErrorStrings.UriQueryExpressionParser_TooDeep);
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:6,代码来源:ODataUriParserTests.cs

示例6: OrderByLimitIsRespectedForOrderby

 public void OrderByLimitIsRespectedForOrderby()
 {
     ODataUriParser parser = new ODataUriParser(HardCodedTestModel.TestModel, ServiceRoot, new Uri("http://host/People?$orderby= 1 eq 1")) { Settings = { OrderByLimit = 0 } };
     Action parseWithLimit = () => parser.ParseOrderBy();
     parseWithLimit.ShouldThrow<ODataException>().WithMessage(ODataErrorStrings.UriQueryExpressionParser_TooDeep);
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:6,代码来源:ODataUriParserTests.cs

示例7: ParseUriAndVerify

        private void ParseUriAndVerify(
            Uri uri,
            Action<ODataPath, FilterClause, OrderByClause, SelectExpandClause, IDictionary<string, SingleValueNode>> verifyAction)
        {
            // run 2 test passes:
            // 1. low level api - ODataUriParser instance methods
            {
                List<CustomQueryOptionToken> queries = UriUtils.ParseQueryOptions(uri);
                ODataUriParser parser = new ODataUriParser(HardCodedTestModel.TestModel, new Uri("http://gobbledygook/"), uri);

                ODataPath path = parser.ParsePath();
                IEdmNavigationSource entitySource = ResolveEntitySource(path);
                IEdmEntitySet entitySet = entitySource as IEdmEntitySet;

                var dic = queries.ToDictionary(customQueryOptionToken => customQueryOptionToken.Name, customQueryOptionToken => queries.GetQueryOptionValue(customQueryOptionToken.Name));
                ODataQueryOptionParser queryOptionParser = new ODataQueryOptionParser(HardCodedTestModel.TestModel, entitySet.EntityType(), entitySet, dic)
                {
                    Configuration = { ParameterAliasValueAccessor = parser.ParameterAliasValueAccessor }
                };

                FilterClause filterClause = queryOptionParser.ParseFilter();
                SelectExpandClause selectExpandClause = queryOptionParser.ParseSelectAndExpand();
                OrderByClause orderByClause = queryOptionParser.ParseOrderBy();

                // Two parser should share same ParameterAliasNodes
                verifyAction(path, filterClause, orderByClause, selectExpandClause, parser.ParameterAliasNodes);
                verifyAction(path, filterClause, orderByClause, selectExpandClause, queryOptionParser.ParameterAliasNodes);
            }

            //2. high level api - ParseUri
            {
                ODataUriParser parser = new ODataUriParser(HardCodedTestModel.TestModel, new Uri("http://gobbledygook/"), uri);
                verifyAction(parser.ParsePath(), parser.ParseFilter(), parser.ParseOrderBy(), parser.ParseSelectAndExpand(), parser.ParameterAliasNodes);
            }
        }
开发者ID:rossjempson,项目名称:odata.net,代码行数:35,代码来源:ParameterAliasFunctionalTests.cs

示例8: ParseWithAllQueryOptionsWithoutAlias

 public void ParseWithAllQueryOptionsWithoutAlias()
 {
     ODataUriParser parser = new ODataUriParser(HardCodedTestModel.TestModel, new Uri("http://www.odata.com/OData/"), new Uri("http://www.odata.com/OData/Dogs?$select=Color, MyPeople&$expand=MyPeople&$filter=startswith(Color, 'Blue')&$orderby=Color asc"));
     parser.ParsePath().FirstSegment.ShouldBeEntitySetSegment(HardCodedTestModel.GetDogsSet());
     var myDogSelectedItems = parser.ParseSelectAndExpand().SelectedItems.ToList();
     myDogSelectedItems.Count.Should().Be(3);
     myDogSelectedItems[1].ShouldBePathSelectionItem(new ODataPath(new PropertySegment(HardCodedTestModel.GetDogColorProp())));
     var myPeopleExpansionSelectionItem = myDogSelectedItems[0].ShouldBeSelectedItemOfType<ExpandedNavigationSelectItem>().And;
     myPeopleExpansionSelectionItem.PathToNavigationProperty.Single().ShouldBeNavigationPropertySegment(HardCodedTestModel.GetDogMyPeopleNavProp());
     myPeopleExpansionSelectionItem.SelectAndExpand.SelectedItems.Should().BeEmpty();
     var startsWithArgs = parser.ParseFilter().Expression.ShouldBeSingleValueFunctionCallQueryNode("startswith").And.Parameters.ToList();
     startsWithArgs[0].ShouldBeSingleValuePropertyAccessQueryNode(HardCodedTestModel.GetDogColorProp());
     startsWithArgs[1].ShouldBeConstantQueryNode("Blue");
     var orderby = parser.ParseOrderBy();
     orderby.Direction.Should().Be(OrderByDirection.Ascending);
     orderby.Expression.ShouldBeSingleValuePropertyAccessQueryNode(HardCodedTestModel.GetDogColorProp());
 }
开发者ID:rossjempson,项目名称:odata.net,代码行数:17,代码来源:FullUriFunctionalTests.cs


注:本文中的Microsoft.OData.Core.UriParser.ODataUriParser.ParseOrderBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。