本文整理汇总了C#中Raven.Abstractions.Data.JsonDocument.Where方法的典型用法代码示例。如果您正苦于以下问题:C# JsonDocument.Where方法的具体用法?C# JsonDocument.Where怎么用?C# JsonDocument.Where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Raven.Abstractions.Data.JsonDocument
的用法示例。
在下文中一共展示了JsonDocument.Where方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FilterIndexes
private IEnumerable<Tuple<IndexToWorkOn, IEnumerable<JsonDocument>>> FilterIndexes(IEnumerable<IndexToWorkOn> indexesToWorkOn, JsonDocument[] jsonDocs)
{
var last = jsonDocs.Last();
Debug.Assert(last.Etag != null);
Debug.Assert(last.LastModified != null);
var lastEtag = last.Etag.Value;
var lastModified = last.LastModified.Value;
var lastIndexedEtag = new ComparableByteArray(lastEtag.ToByteArray());
Action<IStorageActionsAccessor> action = null;
foreach (var indexToWorkOn in indexesToWorkOn)
{
var indexLastInedexEtag = new ComparableByteArray(indexToWorkOn.LastIndexedEtag.ToByteArray());
if (indexLastInedexEtag.CompareTo(lastIndexedEtag) >= 0)
continue;
var filteredDocs = jsonDocs.Where(doc => indexLastInedexEtag.CompareTo(new ComparableByteArray(doc.Etag.Value.ToByteArray())) < 0);
var indexName = indexToWorkOn.IndexName;
var viewGenerator = context.IndexDefinitionStorage.GetViewGenerator(indexName);
if(viewGenerator == null)
continue; // probably deleted
if (viewGenerator.ForEntityNames.Count != 0) // limit for the items that it care for
{
filteredDocs = filteredDocs.Where(x => viewGenerator.ForEntityNames.Contains(x.Metadata.Value<string>(Constants.RavenEntityName)));
}
List<JsonDocument> jsonDocuments = filteredDocs.ToList();
if(jsonDocuments.Count == 0)
{
// we use it this way to batch all the updates together
action += accessor => accessor.Indexing.UpdateLastIndexed(indexName, lastEtag, lastModified);
continue;
}
yield return Tuple.Create<IndexToWorkOn, IEnumerable<JsonDocument>>(indexToWorkOn, jsonDocuments);
}
if (action != null)
{
transactionalStorage.Batch(action);
}
}