本文整理汇总了C#中Raven.Database.Linq.AbstractViewGenerator.TransformResultsDefinition方法的典型用法代码示例。如果您正苦于以下问题:C# AbstractViewGenerator.TransformResultsDefinition方法的具体用法?C# AbstractViewGenerator.TransformResultsDefinition怎么用?C# AbstractViewGenerator.TransformResultsDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Raven.Database.Linq.AbstractViewGenerator
的用法示例。
在下文中一共展示了AbstractViewGenerator.TransformResultsDefinition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetQueryResults
private IEnumerable<RavenJObject> GetQueryResults(IndexQuery query,
AbstractViewGenerator viewGenerator,
DocumentRetriever docRetriever,
IEnumerable<JsonDocument> results,
List<string> transformerErrors)
{
if (query.PageSize <= 0) // maybe they just want the stats?
{
return Enumerable.Empty<RavenJObject>();
}
IndexingFunc transformFunc = null;
// Check an explicitly declared one first
if (query.ResultsTransformer != null)
{
var transformGenerator = IndexDefinitionStorage.GetTransfomer(query.ResultsTransformer);
if (transformGenerator != null && transformGenerator.TransformResultsDefinition != null)
transformFunc = transformGenerator.TransformResultsDefinition;
}
else if (query.SkipTransformResults == false && viewGenerator.TransformResultsDefinition != null)
{
transformFunc = source => viewGenerator.TransformResultsDefinition(docRetriever, source);
}
if (transformFunc == null)
return results.Select(x => x.ToJson());
var dynamicJsonObjects = results.Select(x => new DynamicJsonObject(x.ToJson())).ToArray();
var robustEnumerator = new RobustEnumerator(workContext, dynamicJsonObjects.Length)
{
OnError =
(exception, o) =>
transformerErrors.Add(string.Format("Doc '{0}', Error: {1}", Index.TryGetDocKey(o),
exception.Message))
};
return robustEnumerator.RobustEnumeration(
dynamicJsonObjects.Cast<object>().GetEnumerator(),
transformFunc)
.Select(JsonExtensions.ToJObject);
}
示例2: GetQueryResults
private IEnumerable<RavenJObject> GetQueryResults(IndexQuery query,
AbstractViewGenerator viewGenerator,
DocumentRetriever docRetriever,
IEnumerable<JsonDocument> results,
List<string> transformerErrors,
CancellationToken token)
{
if (query.PageSize <= 0) // maybe they just want the stats?
{
return Enumerable.Empty<RavenJObject>();
}
IndexingFunc transformFunc = null;
// Check an explicitly declared one first
if (string.IsNullOrEmpty(query.ResultsTransformer) == false)
{
var transformGenerator = IndexDefinitionStorage.GetTransformer(query.ResultsTransformer);
if (transformGenerator != null && transformGenerator.TransformResultsDefinition != null)
transformFunc = transformGenerator.TransformResultsDefinition;
else
throw new InvalidOperationException("The transformer " + query.ResultsTransformer + " was not found");
}
else if (query.SkipTransformResults == false && viewGenerator.TransformResultsDefinition != null)
{
transformFunc = source => viewGenerator.TransformResultsDefinition(docRetriever, source);
}
if (transformFunc == null)
return results.Select(x => x.ToJson());
var dynamicJsonObjects = results.Select(x => new DynamicLuceneOrParentDocumntObject(docRetriever, x.ToJson()));
var robustEnumerator = new RobustEnumerator(token, 100)
{
OnError =
(exception, o) =>
transformerErrors.Add(string.Format("Doc '{0}', Error: {1}", Index.TryGetDocKey(o),
exception.Message))
};
return robustEnumerator.RobustEnumeration(
dynamicJsonObjects.Cast<object>().GetEnumerator(),
transformFunc)
.Select(JsonExtensions.ToJObject);
}