本文整理汇总了C#中IHttpContext.GetCutOff方法的典型用法代码示例。如果您正苦于以下问题:C# IHttpContext.GetCutOff方法的具体用法?C# IHttpContext.GetCutOff怎么用?C# IHttpContext.GetCutOff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHttpContext
的用法示例。
在下文中一共展示了IHttpContext.GetCutOff方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnBulkOperation
private void OnBulkOperation(IHttpContext context, Func<string, TransactionInformation, object> batchOperation)
{
var match = urlMatcher.Match(context.GetRequestUrl());
var index = match.Groups[2].Value;
if (string.IsNullOrEmpty(index))
{
context.SetStatusToBadRequest();
return;
}
var allowStale = context.GetAllowStale();
Database.TransactionalStorage.Batch(actions =>
{
bool stale;
var queryResults = Database.QueryDocumentIds(index, new IndexQuery
{
Query = context.Request.QueryString["query"],
Start = context.GetStart(),
PageSize = int.MaxValue, // get all
Cutoff = context.GetCutOff(),
FieldsToFetch = new[] { "__document_id" }
}, out stale);
if (stale)
{
context.SetStatusToNonAuthoritativeInformation();
if (allowStale == false)
{
throw new InvalidOperationException(
"Bulk operation cancelled because the index is stale and allowStale is false");
}
}
var transactionInformation = GetRequestTransaction(context);
var array = new JArray();
foreach (var documentId in queryResults)
{
var result = batchOperation(documentId, transactionInformation);
array.Add(JObject.FromObject(result, new JsonSerializer { Converters = { new JsonEnumConverter() } }));
}
context.WriteJson(array);
});
}
示例2: OnGet
private void OnGet(IHttpContext context, string index)
{
var definition = context.Request.QueryString["definition"];
if ("yes".Equals(definition, StringComparison.InvariantCultureIgnoreCase))
{
context.WriteJson(new {Index = Database.IndexDefinitionStorage.GetIndexDefinition(index)});
}
else
{
context.WriteJson(Database.Query(index, new IndexQuery
{
Query = context.Request.QueryString["query"],
Start = context.GetStart(),
PageSize = context.GetPageSize(),
Cutoff = context.GetCutOff(),
FieldsToFetch = context.Request.QueryString.GetValues("fetch"),
SortedFields = context.Request.QueryString.GetValues("sort")
.EmptyIfNull()
.Select(x => new SortedField(x))
.ToArray()
}));
}
}