public async void Paginate(ObjCode objcode, object parameters, int limit = 2000)
        {
            //todo:I have to fix this in a different way. Do not buggle up Search method 
            double totalCount = await CountOfRecordsAsync(objcode, parameters);
            int pages = (int) totalCount/limit;
            int reminder = (int) totalCount%limit;
            for (int i = 0; i < pages; i++)
            {
                string request = await BuildRequestAsync(objcode, parameters, Operation.Operations.Search);
                await MakeRequestAsync(request);
            }

        }
        /// <summary>
        /// Build request that will be sent to the server 
        /// </summary>
        /// <param name="objCode"></param>
        /// <param name="parameters"></param>
        /// <param name="operationType"></param>
        /// <returns></returns>
        public async Task<string> BuildRequestAsync(ObjCode objCode, object parameters, Operation.Operations operationType)
        {
            var requestResult = Task.Factory.StartNew(async () =>
            {
                string[] fieldsToInclude = parameterObjectToStringArray(parameters, "sessionID=" + SessionID);

                string path = null;

                switch (operationType)
                    {
                    case Operation.Operations.Search:
                        path = string.Format("/{0}/search", objCode);
                        break;
                    case Operation.Operations.Post:
                        path = string.Format("/{0}/post", objCode);
                        break;
                    case Operation.Operations.Delete:
                        path = string.Format("/{0}/delete", objCode);
                        break;
                    case Operation.Operations.Put:
                        path = string.Format("/{0}/put", objCode);
                        break;
                    case Operation.Operations.Count:
                        path = string.Format("/{0}/count", objCode);
                        break;
                    default: //the case for the Get, the default operation
                        break;
                    }


                if (!string.IsNullOrEmpty(path) && !path.StartsWith("/"))
                    {
                    path = "/" + path;
                    }
                _log.LogIt(string.Format("Request is created as {0}",
                    client.url + path + await client.ToQueryStringAsync(fieldsToInclude)));
                return client.url + path + await client.ToQueryStringAsync(fieldsToInclude);
            });
            return await requestResult.Result;
        }
 public async Task<double> CountOfRecordsAsync(ObjCode objCode, object parameters)
 {
     var countResult = Task.Factory.StartNew(async () =>
     {
         string request = await BuildRequestAsync(objCode, parameters, Operation.Operations.Count);
         JToken count = await MakeRequestAsync(request);
         return count.SelectToken("data.count").Value<double>();
     });
     return await countResult.Result;
 }