< Summary

Information
Class: Pozitron.QuerySpecification.WhereEvaluator
Assembly: Pozitron.QuerySpecification
File(s): /home/runner/work/QuerySpecification/QuerySpecification/src/QuerySpecification/Evaluators/WhereEvaluator.cs
Tag: 52_11740816328
Line coverage
100%
Covered lines: 11
Uncovered lines: 0
Coverable lines: 11
Total lines: 43
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 Crap Score Cyclomatic complexity Line 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>
 6public sealed class WhereEvaluator : IEvaluator, IInMemoryEvaluator
 7{
 8    /// <summary>
 9    /// Gets the singleton instance of the <see cref="WhereEvaluator"/> class.
 10    /// </summary>
 211    public static WhereEvaluator Instance = new();
 412    private WhereEvaluator() { }
 13
 14    /// <inheritdoc/>
 15    public IQueryable<T> Evaluate<T>(IQueryable<T> source, Specification<T> specification) where T : class
 16    {
 53417        foreach (var item in specification.Items)
 18        {
 21619            if (item.Type == ItemType.Where && item.Reference is Expression<Func<T, bool>> expr)
 20            {
 5521                source = source.Where(expr);
 22            }
 23        }
 24
 5125        return source;
 26    }
 27
 28    /// <inheritdoc/>
 29    public IEnumerable<T> Evaluate<T>(IEnumerable<T> source, Specification<T> specification)
 30    {
 1431        var compiledItems = specification.GetCompiledItems();
 32
 7833        foreach (var item in compiledItems)
 34        {
 2535            if (item.Type == ItemType.Where && item.Reference is Func<T, bool> compiledExpr)
 36            {
 737                source = source.Where(compiledExpr);
 38            }
 39        }
 40
 1441        return source;
 42    }
 43}