< Summary

Information
Class: Pozitron.QuerySpecification.AsNoTrackingEvaluator
Assembly: Pozitron.QuerySpecification.EntityFrameworkCore
File(s): /home/runner/work/QuerySpecification/QuerySpecification/src/QuerySpecification.EntityFrameworkCore/Evaluators/AsNoTrackingEvaluator.cs
Tag: 52_11740816328
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 24
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
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%22100%

File(s)

/home/runner/work/QuerySpecification/QuerySpecification/src/QuerySpecification.EntityFrameworkCore/Evaluators/AsNoTrackingEvaluator.cs

#LineLine coverage
 1namespace Pozitron.QuerySpecification;
 2
 3/// <summary>
 4/// Evaluator to apply AsNoTracking to the query if the specification has AsNoTracking set to true.
 5/// </summary>
 6public sealed class AsNoTrackingEvaluator : IEvaluator
 7{
 8    /// <summary>
 9    /// Gets the singleton instance of the <see cref="AsNoTrackingEvaluator"/> class.
 10    /// </summary>
 111    public static AsNoTrackingEvaluator Instance = new();
 212    private AsNoTrackingEvaluator() { }
 13
 14    /// <inheritdoc/>
 15    public IQueryable<T> Evaluate<T>(IQueryable<T> source, Specification<T> specification) where T : class
 16    {
 5117        if (specification.AsNoTracking)
 18        {
 219            source = source.AsNoTracking();
 20        }
 21
 5122        return source;
 23    }
 24}