< Summary

Information
Class: Pozitron.QuerySpecification.WhereEvaluator
Assembly: Pozitron.QuerySpecification
File(s): /home/runner/work/QuerySpecification/QuerySpecification/src/QuerySpecification/Evaluators/WhereEvaluator.cs
Tag: 67_15587897385
Line coverage
100%
Covered lines: 11
Uncovered lines: 0
Coverable lines: 11
Total lines: 44
Line coverage: 100%
Branch coverage
100%
Covered branches: 12
Total branches: 12
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.cctor()100%11100%
.ctor()100%11100%
Evaluate(...)100%66100%
Evaluate(...)100%66100%

File(s)

/home/runner/work/QuerySpecification/QuerySpecification/src/QuerySpecification/Evaluators/WhereEvaluator.cs

#LineLine coverage
 1namespace Pozitron.QuerySpecification;
 2
 3/// <summary>
 4/// Represents an evaluator for where expressions.
 5/// </summary>
 6[EvaluatorDiscovery(Order = 10)]
 7public sealed class WhereEvaluator : IEvaluator, IMemoryEvaluator
 8{
 9    /// <summary>
 10    /// Gets the singleton instance of the <see cref="WhereEvaluator"/> class.
 11    /// </summary>
 312    public static WhereEvaluator Instance = new();
 613    private WhereEvaluator() { }
 14
 15    /// <inheritdoc/>
 16    public IQueryable<T> Evaluate<T>(IQueryable<T> source, Specification<T> specification) where T : class
 17    {
 55818        foreach (var item in specification.Items)
 19        {
 22820            if (item.Type == ItemType.Where && item.Reference is Expression<Func<T, bool>> expr)
 21            {
 5522                source = source.Where(expr);
 23            }
 24        }
 25
 5126        return source;
 27    }
 28
 29    /// <inheritdoc/>
 30    public IEnumerable<T> Evaluate<T>(IEnumerable<T> source, Specification<T> specification)
 31    {
 1432        var compiledItems = specification.GetCompiledItems();
 33
 7834        foreach (var item in compiledItems)
 35        {
 2536            if (item.Type == ItemType.Where && item.Reference is Func<T, bool> compiledExpr)
 37            {
 738                source = source.Where(compiledExpr);
 39            }
 40        }
 41
 1442        return source;
 43    }
 44}