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


C# DocumentDatabase.GetIndexDefinition方法代码示例

本文整理汇总了C#中DocumentDatabase.GetIndexDefinition方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentDatabase.GetIndexDefinition方法的具体用法?C# DocumentDatabase.GetIndexDefinition怎么用?C# DocumentDatabase.GetIndexDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DocumentDatabase的用法示例。


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

示例1: SilverlightWasRequested

		public void SilverlightWasRequested(DocumentDatabase database)
		{
			if (database.GetIndexDefinition("Raven/DocumentsByEntityName") == null)
			{
				database.PutIndex("Raven/DocumentsByEntityName", new IndexDefinition
				{
					Map =
						@"from doc in docs 
let Tag = doc[""@metadata""][""Raven-Entity-Name""]
select new { Tag, LastModified = (DateTime)doc[""@metadata""][""Last-Modified""] };",
					Indexes =
					{
						{"Tag", FieldIndexing.NotAnalyzed},
						{"LastModified", FieldIndexing.NotAnalyzed},
					},
					Stores =
					{
						{"Tag", FieldStorage.No},
						{"LastModified", FieldStorage.No}
					},
					TermVectors =
					{
						{"Tag", FieldTermVector.No},
						{"LastModified", FieldTermVector.No}						
					}
				});
			}
		}
开发者ID:925coder,项目名称:ravendb,代码行数:28,代码来源:CreateSilverlightIndexes.cs

示例2: FindIndexName

		private void FindIndexName(DocumentDatabase database, DynamicQueryMapping map, IndexQuery query)
		{
			var targetName = map.ForEntityName ?? "AllDocs";

			var combinedFields = String.Join("And",
				map.Items
				.OrderBy(x => x.To)
				.Select(x => x.To));
			var indexName = combinedFields;

			if (map.SortDescriptors != null && map.SortDescriptors.Length > 0)
			{
				indexName = string.Format("{0}SortBy{1}", indexName,
										  String.Join("",
													  map.SortDescriptors
														  .Select(x => x.Field)
														  .OrderBy(x => x)));
			}
			if (map.HighlightedFields != null && map.HighlightedFields.Length > 0)
			{
				indexName = string.Format("{0}Highlight{1}", indexName,
					string.Join("", map.HighlightedFields.OrderBy(x => x)));
			}
			string groupBy = null;
			if (AggregationOperation != AggregationOperation.None)
			{
				if (query.GroupBy != null && query.GroupBy.Length > 0)
				{
					groupBy += "/" + AggregationOperation + "By" + string.Join("And", query.GroupBy);
				}
				else
				{
					groupBy += "/" + AggregationOperation;
				}
				if (DynamicAggregation)
					groupBy += "Dynamically";
			}

			if (database.Configuration.RunInUnreliableYetFastModeThatIsNotSuitableForProduction == false &&
				database.Configuration.RunInMemory == false)
			{
				// Hash the name if it's too long (as a path)
				if ((database.Configuration.DataDirectory.Length + indexName.Length) > 230)
				{
					using (var sha256 = SHA256.Create())
					{
						var bytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(indexName));
						indexName = Convert.ToBase64String(bytes);
					}
				}
			}

			var permanentIndexName = indexName.Length == 0
					? string.Format("Auto/{0}{1}", targetName, groupBy)
					: string.Format("Auto/{0}/By{1}{2}", targetName, indexName, groupBy);

			var temporaryIndexName = indexName.Length == 0
					? string.Format("Temp/{0}{1}", targetName, groupBy)
					: string.Format("Temp/{0}/By{1}{2}", targetName, indexName, groupBy);


			// If there is a permanent index, then use that without bothering anything else
			var permanentIndex = database.GetIndexDefinition(permanentIndexName);
			map.PermanentIndexName = permanentIndexName;
			map.TemporaryIndexName = temporaryIndexName;
			map.IndexName = permanentIndex != null ? permanentIndexName : temporaryIndexName;
		}
开发者ID:jjchiw,项目名称:ravendb,代码行数:67,代码来源:DynamicQueryMapping.cs


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