本文整理汇总了C#中Raven.Abstractions.Data.IndexQuery.GetIndexQueryUrl方法的典型用法代码示例。如果您正苦于以下问题:C# IndexQuery.GetIndexQueryUrl方法的具体用法?C# IndexQuery.GetIndexQueryUrl怎么用?C# IndexQuery.GetIndexQueryUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Raven.Abstractions.Data.IndexQuery
的用法示例。
在下文中一共展示了IndexQuery.GetIndexQueryUrl方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteByIndexAsync
public Task DeleteByIndexAsync(string indexName, IndexQuery queryToDelete, bool allowStale)
{
string path = queryToDelete.GetIndexQueryUrl(url, indexName, "bulk_docs") + "&allowStale=" + allowStale;
var request = jsonRequestFactory.CreateHttpJsonRequest(
new CreateHttpJsonRequestParams(this, path, "DELETE", credentials, convention)
.AddOperationHeaders(OperationsHeaders));
return request.ExecuteRequestAsync()
.ContinueWith(task =>
{
var aggregateException = task.Exception;
if (aggregateException == null)
return task;
var e = aggregateException.ExtractSingleInnerException() as WebException;
if (e == null)
return task;
var httpWebResponse = e.Response as HttpWebResponse;
if (httpWebResponse != null && httpWebResponse.StatusCode == HttpStatusCode.NotFound)
throw new InvalidOperationException("There is no index named: " + indexName, e);
return task;
}).Unwrap();
}
示例2: QueryAsync
/// <summary>
/// Begins the async query.
/// </summary>
/// <param name="index">The index.</param>
/// <param name="query">The query.</param>
/// <param name="includes">The include paths</param>
public Task<QueryResult> QueryAsync(string index, IndexQuery query, string[] includes)
{
EnsureIsNotNullOrEmpty(index, "index");
var path = query.GetIndexQueryUrl(url, index, "indexes");
if (includes != null && includes.Length > 0)
{
path += "&" + string.Join("&", includes.Select(x => "include=" + x).ToArray());
}
var request = jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, path, "GET", credentials, convention));
return request.ReadResponseJsonAsync()
.ContinueWith(task =>
{
RavenJObject json;
try
{
json = (RavenJObject) task.Result;
}
catch (AggregateException e)
{
var we = e.ExtractSingleInnerException() as WebException;
if(we != null)
{
var httpWebResponse = we.Response as HttpWebResponse;
if (httpWebResponse != null && httpWebResponse.StatusCode == HttpStatusCode.NotFound)
{
var text = new StreamReader(httpWebResponse.GetResponseStreamWithHttpDecompression()).ReadToEnd();
if (text.Contains("maxQueryString"))
throw new InvalidOperationException(text, e);
throw new InvalidOperationException("There is no index named: " + index);
}
}
throw;
}
return new QueryResult
{
IsStale = Convert.ToBoolean(json["IsStale"].ToString()),
IndexTimestamp = json.Value<DateTime>("IndexTimestamp"),
IndexEtag = new Guid(request.ResponseHeaders["ETag"]),
Results = ((RavenJArray)json["Results"]).Cast<RavenJObject>().ToList(),
TotalResults = Convert.ToInt32(json["TotalResults"].ToString()),
IndexName = json.Value<string>("IndexName"),
SkippedResults = Convert.ToInt32(json["SkippedResults"].ToString())
};
});
}
示例3: QueryAsync
/// <summary>
/// Begins the async query.
/// </summary>
/// <param name="index">The index.</param>
/// <param name="query">The query.</param>
/// <param name="includes">The include paths</param>
public Task<QueryResult> QueryAsync(string index, IndexQuery query, string[] includes)
{
EnsureIsNotNullOrEmpty(index, "index");
var path = query.GetIndexQueryUrl(url, index, "indexes");
if (includes != null && includes.Length > 0)
{
path += "&" + string.Join("&", includes.Select(x => "include=" + x).ToArray());
}
var request = jsonRequestFactory.CreateHttpJsonRequest(this, path, "GET", credentials, convention);
return request.ReadResponseStringAsync()
.ContinueWith(task =>
{
RavenJObject json;
using (var reader = new JsonTextReader(new StringReader(task.Result)))
json = (RavenJObject)RavenJToken.Load(reader);
return new QueryResult
{
IsStale = Convert.ToBoolean(json["IsStale"].ToString()),
IndexTimestamp = json.Value<DateTime>("IndexTimestamp"),
IndexEtag = new Guid(request.ResponseHeaders["ETag"]),
Results = ((RavenJArray)json["Results"]).Cast<RavenJObject>().ToList(),
TotalResults = Convert.ToInt32(json["TotalResults"].ToString()),
IndexName = json.Value<string>("IndexName"),
SkippedResults = Convert.ToInt32(json["SkippedResults"].ToString())
};
});
}