< Summary - ZhEaIsNsAaBn.Libraries coverage (affected: 23 packages)

Information
Class: ZhEaIsNsAaBn.Infrastructure.SqlServer.SqlServerStoredProcedureExecutor
Assembly: ZhEaIsNsAaBn.Infrastructure.SqlServer
File(s): /home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/DataBasePackages/ZhEaIsNsAaBn.Infrastructure.SqlServer/SqlServerStoredProcedureExecutor.cs
Line coverage
57%
Covered lines: 11
Uncovered lines: 8
Coverable lines: 19
Total lines: 60
Line coverage: 57.8%
Branch coverage
25%
Covered branches: 1
Total branches: 4
Branch coverage: 25%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetFromSql(...)100%210%
GetFromSqlAsync()100%11100%
OperateFromSql(...)0%620%
OperateFromSqlAsync()50%22100%
RetValParameter()100%11100%

File(s)

/home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/DataBasePackages/ZhEaIsNsAaBn.Infrastructure.SqlServer/SqlServerStoredProcedureExecutor.cs

#LineLine coverage
 1namespace ZhEaIsNsAaBn.Infrastructure.SqlServer;
 2
 3/// <summary>SQL Server <see cref="IStoredProcedureExecutor"/>: <c>EXEC [schema].[proc] @A = @A, …</c> with every value 
 4internal sealed class SqlServerStoredProcedureExecutor : IStoredProcedureExecutor
 5{
 6    public IReadOnlyList<TEntity> GetFromSql< TEntity >( DbContext dbContext, string storedName, int? cmdType, Dictionar
 7        where TEntity : class
 8    {
 09        ArgumentNullException.ThrowIfNull( dbContext );
 10
 011        var (sql, sqlParameters) = SqlServerParameters.StoredProcedureCommand( storedName, cmdType, parameters );
 12
 13
 014        return dbContext.Set<TEntity>().FromSqlRaw( sql, sqlParameters ).AsNoTracking().ToList();
 15    }
 16
 17    public async Task<IReadOnlyList<TEntity>> GetFromSqlAsync< TEntity >(
 18            DbContext dbContext, string storedName, int? cmdType, Dictionary<object, object>[] parameters, CancellationT
 19        )
 20        where TEntity : class
 21    {
 2822        ArgumentNullException.ThrowIfNull( dbContext );
 23
 2824        var (sql, sqlParameters) = SqlServerParameters.StoredProcedureCommand( storedName, cmdType, parameters );
 25
 26
 827        return await dbContext.Set<TEntity>().FromSqlRaw( sql, sqlParameters ).AsNoTracking().ToListAsync( cancellationT
 828    }
 29
 30    public int OperateFromSql( DbContext dbContext, string storedName, int? cmdType, Dictionary<object, object>[] parame
 31    {
 032        ArgumentNullException.ThrowIfNull( dbContext );
 33
 034        var output           = RetValParameter();
 035        var (sql, arguments) = SqlServerParameters.StoredProcedureCommand( storedName, cmdType, parameters, output );
 36
 37
 038        dbContext.Database.ExecuteSqlRaw( sql, arguments );
 39
 40
 041        return output.Value is int value ? value : 0;
 42    }
 43
 44    public async Task<int> OperateFromSqlAsync( DbContext dbContext, string storedName, int? cmdType, Dictionary<object,
 45    {
 846        ArgumentNullException.ThrowIfNull( dbContext );
 47
 848        var output           = RetValParameter();
 849        var (sql, arguments) = SqlServerParameters.StoredProcedureCommand( storedName, cmdType, parameters, output );
 50
 51
 852        await dbContext.Database.ExecuteSqlRawAsync( sql, arguments, cancellationToken ).ConfigureAwait( false );
 53
 54
 855        return output.Value is int value ? value : 0;
 856    }
 57
 58
 859    private static SqlParameter RetValParameter() => new() { ParameterName = "@retVal", DbType = DbType.Int32, Direction
 60}