コード例 #1
0
ファイル: ODataQueryOptions.cs プロジェクト: emreolgun/WebApi
 private void BuildQueryOptions(IDictionary<string, string> queryParameters)
 {
     foreach (var kvp in queryParameters)
     {
         switch (kvp.Key.ToLowerInvariant())
         {
             case "$filter":
                 ThrowIfEmpty(kvp.Value, "$filter");
                 RawValues.Filter = kvp.Value;
                 Filter = new FilterQueryOption(kvp.Value, Context, _queryOptionParser);
                 break;
             case "$orderby":
                 ThrowIfEmpty(kvp.Value, "$orderby");
                 RawValues.OrderBy = kvp.Value;
                 break;
             case "$top":
                 ThrowIfEmpty(kvp.Value, "$top");
                 RawValues.Top = kvp.Value;
                 break;
             case "$skip":
                 ThrowIfEmpty(kvp.Value, "$skip");
                 RawValues.Skip = kvp.Value;
                 break;
             case "$select":
                 RawValues.Select = kvp.Value;
                 break;
             case "$count":
                 ThrowIfEmpty(kvp.Value, "$count");
                 RawValues.Count = kvp.Value;
                 break;
             case "$expand":
                 RawValues.Expand = kvp.Value;
                 break;
             case "$format":
                 RawValues.Format = kvp.Value;
                 break;
             case "$skiptoken":
                 RawValues.SkipToken = kvp.Value;
                 break;
         }
     }
 }
コード例 #2
0
ファイル: ODataQueryOptions.cs プロジェクト: kosinsky/WebApi
        private void BuildQueryOptions(IDictionary <string, string> queryParameters)
        {
            foreach (KeyValuePair <string, string> kvp in queryParameters)
            {
                switch (kvp.Key.ToLowerInvariant())
                {
                case "$filter":
                    ThrowIfEmpty(kvp.Value, "$filter");
                    RawValues.Filter = kvp.Value;
                    Filter           = new FilterQueryOption(kvp.Value, Context, _queryOptionParser);
                    break;

                case "$orderby":
                    ThrowIfEmpty(kvp.Value, "$orderby");
                    RawValues.OrderBy = kvp.Value;
                    OrderBy           = new OrderByQueryOption(kvp.Value, Context, _queryOptionParser);
                    break;

                case "$top":
                    ThrowIfEmpty(kvp.Value, "$top");
                    RawValues.Top = kvp.Value;
                    Top           = new TopQueryOption(kvp.Value, Context, _queryOptionParser);
                    break;

                case "$skip":
                    ThrowIfEmpty(kvp.Value, "$skip");
                    RawValues.Skip = kvp.Value;
                    Skip           = new SkipQueryOption(kvp.Value, Context, _queryOptionParser);
                    break;

                case "$select":
                    RawValues.Select = kvp.Value;
                    break;

                case "$count":
                    ThrowIfEmpty(kvp.Value, "$count");
                    RawValues.Count = kvp.Value;
                    Count           = new CountQueryOption(kvp.Value, Context, _queryOptionParser);
                    break;

                case "$expand":
                    RawValues.Expand = kvp.Value;
                    break;

                case "$format":
                    RawValues.Format = kvp.Value;
                    break;

                case "$skiptoken":
                    RawValues.SkipToken = kvp.Value;
                    SkipToken           = new SkipTokenQueryOption(kvp.Value, Context, _queryOptionParser);
                    break;

                case "$deltatoken":
                    RawValues.DeltaToken = kvp.Value;
                    break;

                case "$apply":
                    ThrowIfEmpty(kvp.Value, "$apply");
                    RawValues.Apply = kvp.Value;
                    Apply           = new ApplyQueryOption(kvp.Value, Context, _queryOptionParser);
                    break;

                case "$compute":
                    ThrowIfEmpty(kvp.Value, "$compute");
                    RawValues.Compute = kvp.Value;
                    Compute           = new ComputeQueryOption(kvp.Value, Context, _queryOptionParser);
                    break;

                default:
                    // we don't throw if we can't recognize the query
                    break;
                }
            }

            if (RawValues.Select != null || RawValues.Expand != null)
            {
                SelectExpand = new SelectExpandQueryOption(RawValues.Select, RawValues.Expand,
                                                           Context, _queryOptionParser);
            }

            if (InternalRequest.IsCountRequest())
            {
                Count = new CountQueryOption(
                    "true",
                    Context,
                    new ODataQueryOptionParser(
                        Context.Model,
                        Context.ElementType,
                        Context.NavigationSource,
                        new Dictionary <string, string> {
                    { "$count", "true" }
                },
                        Context.RequestContainer));
            }
        }