Example #1
0
 public SkipQueryOption(string rawValue, RawQueryOptions rawValues)
 {
     this.rawValues = rawValues;
     if (String.IsNullOrEmpty(rawValue))
     {
         throw new Exception(" Skip rawValue is null");
     }
     int tem;
     if (int.TryParse(rawValue, out tem))
     {
         RawValue = tem;
     }
     else
     {
         throw new Exception("Skip rawValue is not a int");
     }
 }
Example #2
0
        public JsonQueryOptions( HttpRequestMessage request)
        {
            if (request == null)
            {
                throw new Exception("request is null");
            }

            // remember the context and request
            Request = request;

            // Parse the query from request Uri
            RawValues = new RawQueryOptions();
            IEnumerable<KeyValuePair<string, string>> queryParameters = request.GetQueryNameValuePairs();
            foreach (KeyValuePair<string, string> kvp in queryParameters)
            {
                switch (kvp.Key)
                {
                    case "$where":
                        RawValues.Where = kvp.Value;
                        ThrowIfEmpty(kvp.Value, "$where");
                        Where = new FilterQueryOption(kvp.Value);
                        break;
                    case "$orderby":
                        RawValues.OrderBy = kvp.Value;
                        ThrowIfEmpty(kvp.Value, "$orderby");
                        OrderBy = new OrderByQueryOption(kvp.Value);
                        break;
                    case "$top":
                        RawValues.Top = kvp.Value;
                        ThrowIfEmpty(kvp.Value, "$top");
                        Top = new TopQueryOption(kvp.Value);
                        break;
                    case "$skip":
                        RawValues.Skip = kvp.Value;
                        ThrowIfEmpty(kvp.Value, "$skip");
                        Skip = new SkipQueryOption(kvp.Value, RawValues);
                        break;
                    case "$skiptoken":
                        RawValues.SkipToken = kvp.Value;
                        break;
                    default:
                        // we don't throw if we can't recognize the query
                        break;
                }
            }
        }