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


C# IndexQuery.GetIndexQueryUrl方法代码示例

本文整理汇总了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();
		}
开发者ID:ryanheath,项目名称:ravendb,代码行数:22,代码来源:AsyncServerClient.cs

示例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())
					};
				});

		}
开发者ID:ryanheath,项目名称:ravendb,代码行数:54,代码来源:AsyncServerClient.cs

示例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())
					};
				});

		}
开发者ID:nicolasgarfinkiel,项目名称:ravendb,代码行数:36,代码来源:AsyncServerClient.cs


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