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


C# ODataUriParser.ParseSelectAndExpand方法代码示例

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


在下文中一共展示了ODataUriParser.ParseSelectAndExpand方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例4: SelectExpandLimitIsRespectedForSelectExpand

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

示例5: ParseSelectExpandForContainment

 public void ParseSelectExpandForContainment()
 {
     ODataUriParser parser = new ODataUriParser(HardCodedTestModel.TestModel, ServiceRoot, new Uri("http://host/People?$select=MyContainedDog&$expand=MyContainedDog")) { Settings = { SelectExpandLimit = 5 } };
     SelectExpandClause containedSelectExpandClause = parser.ParseSelectAndExpand();
     IEnumerator<SelectItem> enumerator = containedSelectExpandClause.SelectedItems.GetEnumerator();
     enumerator.MoveNext();
     ExpandedNavigationSelectItem expandedNavigationSelectItem = enumerator.Current as ExpandedNavigationSelectItem;
     expandedNavigationSelectItem.Should().NotBeNull();
     (expandedNavigationSelectItem.NavigationSource is IEdmContainedEntitySet).Should().BeTrue();
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:10,代码来源:ODataUriParserTests.cs

示例6: MaxExpandCountSettingShouldBeEnforced

 public void MaxExpandCountSettingShouldBeEnforced()
 {
     ODataUriParser parser = new ODataUriParser(HardCodedTestModel.TestModel, new Uri("http://host/"), new Uri("http://host/People?$expand=MyDog,MyLions"));
     parser.Settings.MaximumExpansionCount = 1;
     Action parse = () => parser.ParseSelectAndExpand();
     parse.ShouldThrow<ODataException>().WithMessage(ODataErrorStrings.UriParser_ExpandCountExceeded(2, 1));
 }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:7,代码来源:SelectExpandFunctionalTests.cs

示例7: GetWriterSettings

        protected override ODataMessageWriterSettings GetWriterSettings()
        {
            ODataMessageWriterSettings settings = new ODataMessageWriterSettings
            {
                AutoComputePayloadMetadataInJson = true,
                PayloadBaseUri = this.ServiceRootUri
            };

            ODataUriParser uriParser = new ODataUriParser(this.DataSource.Model, ServiceConstants.ServiceBaseUri, originalUri);
            settings.ODataUri = new ODataUri()
            {
                RequestUri = originalUri,
                ServiceRoot = this.ServiceRootUri,
                Path = uriParser.ParsePath(),
                SelectAndExpand = uriParser.ParseSelectAndExpand()
            };

            // TODO: howang read the encoding from request.
            settings.SetContentType(string.IsNullOrEmpty(this.QueryContext.FormatOption) ? this.RequestAcceptHeader : this.QueryContext.FormatOption, Encoding.UTF8.WebName);
            return settings;
        }
开发者ID:chinadragon0515,项目名称:ODataSamples,代码行数:21,代码来源:DeltaLinkHandler.cs

示例8: ExpandedEntryTest

        public void ExpandedEntryTest()
        {
            foreach (var mimeType in this.mimeTypes)
            {
                foreach (var hasModel in this.hasModelFlagBools)
                {
                    const string selectClause = "CustomerId,Video,Orders";
                    const string expandClause = "Logins($select=Username;$expand=SentMessages)";
                    const string expectedClause = "CustomerId,Video,Orders,Logins,Logins(Username,SentMessages)";
                    var uriParser = new ODataUriParser(WritePayloadHelper.Model, WritePayloadHelper.ServiceUri, new Uri(this.ServiceUri, "Customer?$select=" + selectClause + "&$expand=" + expandClause));
                    var result = uriParser.ParseSelectAndExpand();
                    var settings = new ODataMessageWriterSettings();
                    settings.ODataUri = new ODataUri() { ServiceRoot = this.ServiceUri, SelectAndExpand = result };

                    settings.PayloadBaseUri = this.ServiceUri;

                    settings.AutoComputePayloadMetadataInJson = false;
                    string defaultModeResult = this.WriteAndVerifyExpandedCustomerEntry(settings, mimeType, expectedClause, hasModel);

                    settings.AutoComputePayloadMetadataInJson = true;
                    string autoComputeMetadataModeResult = this.WriteAndVerifyExpandedCustomerEntry(settings, mimeType, expectedClause, hasModel);

                    // For Atom, verify that the result is the same for AutoComputePayloadMetadataInJson=true/false
                    if (mimeType == MimeTypes.ApplicationAtomXml)
                    {
                        WritePayloadHelper.VerifyPayloadString(defaultModeResult, autoComputeMetadataModeResult, mimeType);
                    }
                }
            }
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:30,代码来源:AutoComputePayloadMetadataInJsonTests.cs

示例9: 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

示例10: 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.ParseSelectAndExpand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。