本文整理汇总了C#中DocumentRetriever.ExecuteReadTriggers方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentRetriever.ExecuteReadTriggers方法的具体用法?C# DocumentRetriever.ExecuteReadTriggers怎么用?C# DocumentRetriever.ExecuteReadTriggers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DocumentRetriever
的用法示例。
在下文中一共展示了DocumentRetriever.ExecuteReadTriggers方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDocuments
public void GetDocuments(int start, int pageSize, Etag etag, Action<RavenJObject> addDocument)
{
TransactionalStorage.Batch(actions =>
{
bool returnedDocs = false;
while (true)
{
var documents = etag == null
? actions.Documents.GetDocumentsByReverseUpdateOrder(start, pageSize)
: actions.Documents.GetDocumentsAfter(etag, pageSize);
var documentRetriever = new DocumentRetriever(actions, ReadTriggers);
int docCount = 0;
foreach (var doc in documents)
{
docCount++;
if (etag != null)
etag = doc.Etag;
DocumentRetriever.EnsureIdInMetadata(doc);
var document = documentRetriever
.ExecuteReadTriggers(doc, null, ReadOperation.Load);
if (document == null)
continue;
addDocument(document.ToJson());
returnedDocs = true;
}
if (returnedDocs || docCount == 0)
break;
start += docCount;
}
});
}
示例2: GetDocuments
public RavenJArray GetDocuments(int start, int pageSize, Guid? etag)
{
var list = new RavenJArray();
TransactionalStorage.Batch(actions =>
{
IEnumerable<JsonDocument> documents;
if (etag == null)
documents = actions.Documents.GetDocumentsByReverseUpdateOrder(start);
else
documents = actions.Documents.GetDocumentsAfter(etag.Value);
var documentRetriever = new DocumentRetriever(actions, ReadTriggers);
foreach (var doc in documents.Take(pageSize))
{
DocumentRetriever.EnsureIdInMetadata(doc);
var document = documentRetriever
.ExecuteReadTriggers(doc, null, ReadOperation.Load);
if (document == null)
continue;
list.Add(document.ToJson());
}
});
return list;
}
示例3: GetDocumentsWithIdStartingWith
public void GetDocumentsWithIdStartingWith(string idPrefix, string matches, int start, int pageSize, Action<RavenJObject> addDoc)
{
if (idPrefix == null)
throw new ArgumentNullException("idPrefix");
idPrefix = idPrefix.Trim();
TransactionalStorage.Batch(actions =>
{
bool returnedDocs = false;
while (true)
{
int docCount = 0;
var documents = actions.Documents.GetDocumentsWithIdStartingWith(idPrefix, start, pageSize);
var documentRetriever = new DocumentRetriever(actions, ReadTriggers);
foreach (var doc in documents)
{
docCount++;
if (WildcardMatcher.Matches(matches, doc.Key.Substring(idPrefix.Length)) == false)
continue;
DocumentRetriever.EnsureIdInMetadata(doc);
var document = documentRetriever
.ExecuteReadTriggers(doc, null, ReadOperation.Load);
if (document == null)
continue;
addDoc(document.ToJson());
returnedDocs = true;
}
if (returnedDocs || docCount == 0)
break;
start += docCount;
}
});
}
示例4: GetDocuments
public RavenJArray GetDocuments(int start, int pageSize, Guid? etag)
{
var list = new RavenJArray();
TransactionalStorage.Batch(actions =>
{
while (true)
{
var documents = etag == null ?
actions.Documents.GetDocumentsByReverseUpdateOrder(start, pageSize) :
actions.Documents.GetDocumentsAfter(etag.Value, pageSize);
var documentRetriever = new DocumentRetriever(actions, ReadTriggers);
int docCount = 0;
foreach (var doc in documents)
{
docCount++;
if(etag != null)
etag = doc.Etag;
DocumentRetriever.EnsureIdInMetadata(doc);
var document = documentRetriever
.ExecuteReadTriggers(doc, null, ReadOperation.Load);
if (document == null)
continue;
list.Add(document.ToJson());
}
if (list.Length != 0 || docCount == 0)
break;
start += docCount;
}
});
return list;
}
示例5: GetDocumentsWithIdStartingWith
public RavenJArray GetDocumentsWithIdStartingWith(string idPrefix, int start, int pageSize)
{
var list = new RavenJArray();
TransactionalStorage.Batch(actions =>
{
var documents = actions.Documents.GetDocumentsWithIdStartingWith(idPrefix, start)
.Take(pageSize);
var documentRetriever = new DocumentRetriever(actions, ReadTriggers);
foreach (var doc in documents)
{
DocumentRetriever.EnsureIdInMetadata(doc);
var document = documentRetriever
.ExecuteReadTriggers(doc, null, ReadOperation.Load);
if (document == null)
continue;
list.Add(document.ToJson());
}
});
return list;
}
示例6: GetDocumentsWithIdStartingWith
public void GetDocumentsWithIdStartingWith(string idPrefix, string matches, string exclude, int start, int pageSize, Action<RavenJObject> addDoc)
{
if (idPrefix == null)
throw new ArgumentNullException("idPrefix");
idPrefix = idPrefix.Trim();
TransactionalStorage.Batch(actions =>
{
bool returnedDocs = false;
while (true)
{
int docCount = 0;
var documents = actions.Documents.GetDocumentsWithIdStartingWith(idPrefix, start, pageSize);
var documentRetriever = new DocumentRetriever(actions, ReadTriggers, inFlightTransactionalState);
foreach (var doc in documents)
{
docCount++;
string keyTest = doc.Key.Substring(idPrefix.Length);
if (!WildcardMatcher.Matches(matches, keyTest) || WildcardMatcher.MatchesExclusion(exclude, keyTest))
continue;
DocumentRetriever.EnsureIdInMetadata(doc);
var nonAuthoritativeInformationBehavior = inFlightTransactionalState.GetNonAuthoritativeInformationBehavior<JsonDocument>(null, doc.Key);
JsonDocument document = nonAuthoritativeInformationBehavior != null ? nonAuthoritativeInformationBehavior(doc) : doc;
document = documentRetriever
.ExecuteReadTriggers(doc, null, ReadOperation.Load);
if (document == null)
continue;
addDoc(document.ToJson());
returnedDocs = true;
}
if (returnedDocs || docCount == 0)
break;
start += docCount;
}
});
}
示例7: GetDocuments
public void GetDocuments(int start, int pageSize, Etag etag, CancellationToken token, Action<RavenJObject> addDocument)
{
TransactionalStorage.Batch(actions =>
{
bool returnedDocs = false;
while (true)
{
var documents = etag == null
? actions.Documents.GetDocumentsByReverseUpdateOrder(start, pageSize)
: actions.Documents.GetDocumentsAfter(etag, pageSize);
var documentRetriever = new DocumentRetriever(actions, ReadTriggers, inFlightTransactionalState);
int docCount = 0;
foreach (var doc in documents)
{
docCount++;
token.ThrowIfCancellationRequested();
if (etag != null)
etag = doc.Etag;
DocumentRetriever.EnsureIdInMetadata(doc);
var nonAuthoritativeInformationBehavior = inFlightTransactionalState.GetNonAuthoritativeInformationBehavior<JsonDocument>(null, doc.Key);
var document = nonAuthoritativeInformationBehavior == null ? doc : nonAuthoritativeInformationBehavior(doc);
document = documentRetriever
.ExecuteReadTriggers(document, null, ReadOperation.Load);
if (document == null)
continue;
addDocument(document.ToJson());
returnedDocs = true;
}
if (returnedDocs || docCount == 0)
break;
start += docCount;
}
});
}
示例8: GetDocumentsWithIdStartingWith
public void GetDocumentsWithIdStartingWith(string idPrefix, string matches, string exclude, int start, int pageSize, CancellationToken token, Action<RavenJObject> addDoc)
{
if (idPrefix == null)
throw new ArgumentNullException("idPrefix");
idPrefix = idPrefix.Trim();
TransactionalStorage.Batch(
actions =>
{
var docsToSkip = start;
var addedDocs = 0;
var matchedDocs = 0;
int docCount;
start = 0;
do
{
docCount = 0;
var docs = actions.Documents.GetDocumentsWithIdStartingWith(idPrefix, start, pageSize);
var documentRetriever = new DocumentRetriever(actions, ReadTriggers, inFlightTransactionalState);
foreach (var doc in docs)
{
token.ThrowIfCancellationRequested();
docCount++;
var keyTest = doc.Key.Substring(idPrefix.Length);
if (!WildcardMatcher.Matches(matches, keyTest) || WildcardMatcher.MatchesExclusion(exclude, keyTest))
continue;
DocumentRetriever.EnsureIdInMetadata(doc);
var nonAuthoritativeInformationBehavior = inFlightTransactionalState.GetNonAuthoritativeInformationBehavior<JsonDocument>(null, doc.Key);
var document = nonAuthoritativeInformationBehavior != null ? nonAuthoritativeInformationBehavior(doc) : doc;
document = documentRetriever.ExecuteReadTriggers(document, null, ReadOperation.Load);
if (document == null)
continue;
matchedDocs++;
if (matchedDocs <= docsToSkip)
continue;
token.ThrowIfCancellationRequested();
addDoc(document.ToJson());
addedDocs++;
if (addedDocs >= pageSize)
break;
}
start += pageSize;
}
while (docCount > 0 && addedDocs < pageSize && start >= 0 && start < int.MaxValue);
});
}
示例9: GetDocumentsWithIdStartingWith
public RavenJArray GetDocumentsWithIdStartingWith(string idPrefix, string matches, int start, int pageSize)
{
if (idPrefix == null)
throw new ArgumentNullException("idPrefix");
idPrefix = idPrefix.Trim();
var list = new RavenJArray();
TransactionalStorage.Batch(actions =>
{
var documents = actions.Documents.GetDocumentsWithIdStartingWith(idPrefix, start, pageSize);
var documentRetriever = new DocumentRetriever(actions, ReadTriggers);
foreach (var doc in documents)
{
if (WildcardMatcher.Matches(matches, doc.Key.Substring(idPrefix.Length)) == false)
continue;
DocumentRetriever.EnsureIdInMetadata(doc);
var document = documentRetriever
.ExecuteReadTriggers(doc, null, ReadOperation.Load);
if (document == null)
continue;
list.Add(document.ToJson());
}
});
return list;
}
示例10: GetDocuments
public JArray GetDocuments(int start, int pageSize, Guid? etag)
{
var list = new JArray();
TransactionalStorage.Batch(actions =>
{
IEnumerable<JsonDocument> documents;
if (etag == null)
documents = actions.Documents.GetDocumentsByReverseUpdateOrder(start);
else
documents = actions.Documents.GetDocumentsAfter(etag.Value);
var documentRetriever = new DocumentRetriever(actions, ReadTriggers);
foreach (var doc in documents.Take(pageSize))
{
var document = documentRetriever.ExecuteReadTriggers(doc, null,
// here we want to have the Load semantic, not Query, because we need this to be
// as close as possible to the full database contents
ReadOperation.Load);
if (document == null)
continue;
if (document.Metadata.Property("@id") == null)
document.Metadata.Add("@id", new JValue(doc.Key));
list.Add(document.ToJson());
}
});
return list;
}