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


C# IndexQuery类代码示例

本文整理汇总了C#中IndexQuery的典型用法代码示例。如果您正苦于以下问题:C# IndexQuery类的具体用法?C# IndexQuery怎么用?C# IndexQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IndexQuery类属于命名空间,在下文中一共展示了IndexQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetIndexQueryFromHttpContext

        public static IndexQuery GetIndexQueryFromHttpContext(this IHttpContext context, int maxPageSize)
        {
            var query = new IndexQuery
            {
                Query = context.Request.QueryString["query"] ?? "",
                Start = context.GetStart(),
                Cutoff = context.GetCutOff(),
                PageSize = context.GetPageSize(maxPageSize),
                SkipTransformResults = context.GetSkipTransformResults(),
                FieldsToFetch = context.Request.QueryString.GetValues("fetch"),
				GroupBy = context.Request.QueryString.GetValues("groupBy"),
				AggregationOperation = context.GetAggregationOperation(),
                SortedFields = context.Request.QueryString.GetValues("sort")
                    .EmptyIfNull()
                    .Select(x => new SortedField(x))
                    .ToArray()
            };

            double lat = context.GetLat(), lng = context.GetLng(), radius = context.GetRadius();
            if (lat != 0 || lng != 0 || radius != 0)
            {
                return new SpatialIndexQuery(query)
                {
                    Latitude = lat,
                    Longitude = lng,
                    Radius = radius,
                };
            }
            return query;
        }
开发者ID:kblooie,项目名称:ravendb,代码行数:30,代码来源:HttpContextExtensions.cs

示例2: FindDynamicIndexName

		public static string FindDynamicIndexName(this DocumentDatabase self, string entityName, IndexQuery query)
		{
            var result = new DynamicQueryOptimizer(self).SelectAppropriateIndex(entityName, query.Clone());
		    if (result.MatchType == DynamicQueryMatchType.Complete)
		        return result.IndexName;
		    return null;
		}
开发者ID:robashton,项目名称:ravendb,代码行数:7,代码来源:DynamicQueryExtensions.cs

示例3: ExecuteActualQuery

		private QueryResult ExecuteActualQuery(IndexQuery query, DynamicQueryMapping map, Tuple<string, bool> touchTemporaryIndexResult, string realQuery)
		{
			// Perform the query until we have some results at least
			QueryResult result;
			var sp = Stopwatch.StartNew();
			while (true)
			{
				result = documentDatabase.Query(map.IndexName,
				                                new IndexQuery
				                                {
				                                	Cutoff = query.Cutoff,
				                                	PageSize = query.PageSize,
				                                	Query = realQuery,
				                                	Start = query.Start,
				                                	FieldsToFetch = query.FieldsToFetch,
				                                	GroupBy = query.GroupBy,
				                                	AggregationOperation = query.AggregationOperation,
				                                	SortedFields = query.SortedFields,
				                                });

				if (!touchTemporaryIndexResult.Item2 ||
				    !result.IsStale ||
				    result.Results.Count >= query.PageSize ||
				    sp.Elapsed.TotalSeconds > 15)
				{
					return result;
				}

				Thread.Sleep(100);
			}
		}
开发者ID:nzdunic,项目名称:ravendb,代码行数:31,代码来源:DynamicQueryRunner.cs

示例4: Query

        public QueryResultWithIncludes Query(string index, IndexQuery query, CancellationToken externalCancellationToken)
        {
            QueryResultWithIncludes result = null;
            using (var cts = CancellationTokenSource.CreateLinkedTokenSource(externalCancellationToken, WorkContext.CancellationToken))
            {
                var cancellationToken = cts.Token;

                TransactionalStorage.Batch(
                    accessor =>
                    {
                        using (var op = new DatabaseQueryOperation(Database, index, query, accessor, cancellationToken)
                        {
                            ShouldSkipDuplicateChecking = query.SkipDuplicateChecking
                        })
                        {
                            var list = new List<RavenJObject>();
                            op.Init();
                            op.Execute(list.Add);
                            op.Result.Results = list;
                            result = op.Result;
                        }
                    });
            }

            return result;
        }
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:26,代码来源:QueryActions.cs

示例5: ExplainDynamicIndexSelection

		public static List<DynamicQueryOptimizer.Explanation> ExplainDynamicIndexSelection(this DocumentDatabase self, string entityName, IndexQuery query)
		{
			var explanations = new List<DynamicQueryOptimizer.Explanation>();
			new DynamicQueryOptimizer(self)
				.SelectAppropriateIndex(entityName, query.Clone(), explanations);
			return explanations;
		}
开发者ID:robashton,项目名称:ravendb,代码行数:7,代码来源:DynamicQueryExtensions.cs

示例6: ExecutingQueryInfo

 public ExecutingQueryInfo(DateTime startTime, IndexQuery queryInfo, long queryId, CancellationTokenSource tokenSource)
 {
     StartTime = startTime;
     QueryInfo = queryInfo;
     QueryId = queryId;
     stopwatch = Stopwatch.StartNew();
     TokenSource = tokenSource;
 }
开发者ID:j2jensen,项目名称:ravendb,代码行数:8,代码来源:ExecutingQueryInfo.cs

示例7: DeleteByIndex

		public RavenJArray DeleteByIndex(string indexName, IndexQuery queryToDelete, bool allowStale)
		{
			return PerformBulkOperation(indexName, queryToDelete, allowStale, (docId, tx) =>
			{
				database.Delete(docId, null, tx);
				return new { Document = docId, Deleted = true };
			});
		}
开发者ID:jtmueller,项目名称:ravendb,代码行数:8,代码来源:DatabaseBulkOperations.cs

示例8: UpdateByIndex

		public RavenJArray UpdateByIndex(string indexName, IndexQuery queryToUpdate, PatchRequest[] patchRequests, bool allowStale)
		{
			return PerformBulkOperation(indexName, queryToUpdate, allowStale, (docId, tx) =>
			{
				var patchResult = database.ApplyPatch(docId, null, patchRequests, tx);
				return new { Document = docId, Result = patchResult };
			});
		}
开发者ID:jtmueller,项目名称:ravendb,代码行数:8,代码来源:DatabaseBulkOperations.cs

示例9: DeleteByIndex

        public RavenJArray DeleteByIndex(string indexName, IndexQuery queryToDelete, BulkOperationOptions options = null)
        {
            return PerformBulkOperation(indexName, queryToDelete, options, (docId, tx) =>
			{
				database.Documents.Delete(docId, null, tx);
				return new { Document = docId, Deleted = true };
			});
		}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:8,代码来源:DatabaseBulkOperations.cs

示例10: UpdateByIndex

        public RavenJArray UpdateByIndex(string indexName, IndexQuery queryToUpdate, ScriptedPatchRequest patch, BulkOperationOptions options = null)
		{
            return PerformBulkOperation(indexName, queryToUpdate, options, (docId, tx) =>
			{
				var patchResult = database.Patches.ApplyPatch(docId, null, patch, tx);
				return new { Document = docId, Result = patchResult.Item1, Debug = patchResult.Item2 };
			});
		}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:8,代码来源:DatabaseBulkOperations.cs

示例11: Index

        // GET: Campaign
        public async Task<IActionResult> Index()
        {
            var query = new IndexQuery();
            if (User.IsUserType(UserType.OrgAdmin))
            {
                query.OrganizationId = User.GetOrganizationId();
            }

            return View(await _mediator.SendAsync(query));
        }
开发者ID:nicolastarzia,项目名称:allReady,代码行数:11,代码来源:CampaignController.cs

示例12: UpdateFieldNamesForSortedFields

		private static void UpdateFieldNamesForSortedFields(IndexQuery query, DynamicQueryMapping map)
		{
			if (query.SortedFields == null) return;
			foreach (var sortedField in query.SortedFields)
			{
				var item = map.Items.FirstOrDefault(x => x.From == sortedField.Field);
				if (item != null)
					sortedField.Field = item.To;
			}
		}
开发者ID:samueldjack,项目名称:ravendb,代码行数:10,代码来源:DynamicQueryRunner.cs

示例13: CreateIndexQuery

        private static IndexQuery CreateIndexQuery(IndexQuery query, DynamicQueryMapping map, string realQuery)
        {
            var indexQuery = new IndexQuery
            {
                Cutoff = query.Cutoff,
                WaitForNonStaleResultsAsOfNow = query.WaitForNonStaleResultsAsOfNow,
                PageSize = query.PageSize,
                Query = realQuery,
                Start = query.Start,
                FieldsToFetch = query.FieldsToFetch,
                IsDistinct = query.IsDistinct,
                SortedFields = query.SortedFields,
                DefaultField = query.DefaultField,
                CutoffEtag = query.CutoffEtag,
                DebugOptionGetIndexEntries = query.DebugOptionGetIndexEntries,
                DefaultOperator = query.DefaultOperator,
                SkippedResults = query.SkippedResults,
                HighlighterPreTags = query.HighlighterPreTags,
                HighlighterPostTags = query.HighlighterPostTags,
                HighlightedFields = query.HighlightedFields,
                HighlighterKeyName = query.HighlighterKeyName,
                ResultsTransformer = query.ResultsTransformer,
                TransformerParameters = query.TransformerParameters,
                ExplainScores = query.ExplainScores,
                SortHints = query.SortHints,
                ShowTimings = query.ShowTimings,
                AllowMultipleIndexEntriesForSameDocumentToResultTransformer = query.AllowMultipleIndexEntriesForSameDocumentToResultTransformer,
                DisableCaching = query.DisableCaching,
                SkipDuplicateChecking = query.SkipDuplicateChecking,
                WaitForNonStaleResults = query.WaitForNonStaleResults
                
            };
            if (indexQuery.SortedFields == null)
                return indexQuery;

            for (int index = 0; index < indexQuery.SortedFields.Length; index++)
            {
                var sortedField = indexQuery.SortedFields[index];
                var fieldName = sortedField.Field;
                bool hasRange = false;
                if (fieldName.EndsWith("_Range"))
                {
                    fieldName = fieldName.Substring(0, fieldName.Length - "_Range".Length);
                    hasRange = true;
                }
            
                var item = map.Items.FirstOrDefault(x => string.Equals(x.QueryFrom, fieldName, StringComparison.InvariantCultureIgnoreCase));
                if (item == null)
                    continue;

                indexQuery.SortedFields[index] = new SortedField(hasRange ? item.To + "_Range" : item.To);
                indexQuery.SortedFields[index].Descending = sortedField.Descending;
            }
            return indexQuery;
        }
开发者ID:IdanHaim,项目名称:ravendb,代码行数:55,代码来源:DynamicQueryRunner.cs

示例14: can_encode_and_decode_IndexQuery_PageSize

		public void can_encode_and_decode_IndexQuery_PageSize()
		{
			var expected = Some.Integer();
			var indexQuery = new IndexQuery();

			indexQuery.PageSize = expected;

			IndexQuery result = EncodeAndDecodeIndexQuery(indexQuery);

			Assert.Equal(expected, result.PageSize);
		}
开发者ID:robashton,项目名称:ravendb,代码行数:11,代码来源:IndexQueryUrl.cs

示例15: can_encode_and_decode_IndexQuery_Start

		public void can_encode_and_decode_IndexQuery_Start() 
		{
			int expected = Some.Integer();
			var indexQuery = new IndexQuery();

			indexQuery.Start = expected;

			IndexQuery result = EncodeAndDecodeIndexQuery(indexQuery);

			Assert.Equal(expected, result.Start);
		}
开发者ID:robashton,项目名称:ravendb,代码行数:11,代码来源:IndexQueryUrl.cs


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