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


C# RavenJObject.ToLookup方法代码示例

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


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

示例1: Index

        private void Index(IndexWriter writer, string key, RavenJObject metadata, Etag etag, bool recreateSearcher)
        {
            if (filesystem.ReadTriggers.CanReadFile(key, metadata, ReadOperation.Index) == false)
                return;

            lock (writerLock)
            {
                var lowerKey = key.ToLowerInvariant();

                var doc = CreateDocument(lowerKey, metadata);

                // REVIEW: Check if there is more straight-forward/efficient pattern out there to work with RavenJObjects.
                var lookup = metadata.ToLookup(x => x.Key);
                foreach (var metadataKey in lookup)
                {
                    foreach (var metadataHolder in metadataKey)
                    {
                        var array = metadataHolder.Value as RavenJArray;
                        if (array != null)
                        {
                            // Object is an array. Therefore, we index each token. 
                            foreach (var item in array)
                                AddField(doc, metadataHolder.Key, item.ToString());
                        }
                        else
                        {
                            AddField(doc, metadataHolder.Key, metadataHolder.Value.ToString());
                        }                            
                    }
                }

                if (doc.GetField(Constants.MetadataEtagField) == null)
                    doc.Add(new Field(Constants.MetadataEtagField, etag.ToString(), Field.Store.NO, Field.Index.ANALYZED_NO_NORMS));

                writer.DeleteDocuments(new Term("__key", lowerKey));
                writer.AddDocument(doc);

                var customCommitData = new Dictionary<string, string> { { "LastETag", etag.ToString() } };
                writer.Commit(customCommitData);

                if (recreateSearcher)
                    ReplaceSearcher(writer);
            }
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:44,代码来源:IndexStorage.cs

示例2: Index

        public virtual void Index(string key, RavenJObject metadata)
        {
            lock (writerLock)
            {
                var lowerKey = key.ToLowerInvariant();

                var doc = CreateDocument(lowerKey, metadata);

                // REVIEW: Check if there is more straight-forward/efficient pattern out there to work with RavenJObjects.
                var lookup = metadata.ToLookup(x => x.Key);
                foreach ( var metadataKey in lookup )
                {
                    foreach ( var metadataHolder in metadataKey )
                    {
                        var array = metadataHolder.Value as RavenJArray;
                        if (array != null)
                        {
                            // Object is an array. Therefore, we index each token. 
                            foreach (var item in array)
                                doc.Add(new Field(metadataHolder.Key, item.ToString(), Field.Store.NO, Field.Index.ANALYZED_NO_NORMS));                         
                        }
                        else doc.Add(new Field(metadataHolder.Key, metadataHolder.Value.ToString(), Field.Store.NO, Field.Index.ANALYZED_NO_NORMS));
                    }
                }

                writer.DeleteDocuments(new Term("__key", lowerKey));
                writer.AddDocument(doc);
                // yes, this is slow, but we aren't expecting high writes count
                writer.Commit();
                ReplaceSearcher();
            }
        }
开发者ID:felixmm,项目名称:ravendb,代码行数:32,代码来源:IndexStorage.cs


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