< Summary - SonghayCore

Information
Class: Songhay.Extensions.DataSetExtensions
Assembly: SonghayCore
File(s): /home/rasx/sourceRoot/SonghayCore/SonghayCore/Extensions/DataSetExtensions.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 17
Coverable lines: 17
Total lines: 63
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 8
Branch coverage: 0%
Method coverage

Method coverage is only available for sponsors.

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
ToFirstTableDataRows(...)0%40%
ToFirstTableFirstColumn(...)100%10%
ToFirstTableFirstColumn(...)0%20%
ToFirstTableRows(...)100%10%
ToFirstTableRows(...)0%20%

File(s)

/home/rasx/sourceRoot/SonghayCore/SonghayCore/Extensions/DataSetExtensions.cs

#LineLine coverage
 1using System.Data;
 2
 3namespace Songhay.Extensions;
 4
 5/// <summary>
 6/// Extensions of <see cref="DataSet"/>.
 7/// </summary>
 8public static class DataSetExtensions
 9{
 10    /// <summary>
 11    /// Converts the <see cref="DataSet"/> into a first table data rows.
 12    /// </summary>
 13    /// <param name="dataSet">The data set.</param>
 14    public static IEnumerable<DataRow> ToFirstTableDataRows(this DataSet? dataSet)
 015    {
 016        if (dataSet == null) return Enumerable.Empty<DataRow>();
 17
 018        var table = dataSet
 019            .Tables.OfType<DataTable>()
 020            .FirstOrDefault();
 21
 022        return table == null ? Enumerable.Empty<DataRow>() : table.Rows.OfType<DataRow>();
 023    }
 24
 25    /// <summary>
 26    /// Converts the <see cref="DataSet"/> into a first table first column.
 27    /// </summary>
 28    /// <param name="dataSet">The data set.</param>
 29    public static IEnumerable<string> ToFirstTableFirstColumn(this DataSet? dataSet) =>
 030        dataSet.ToFirstTableFirstColumn<string>();
 31
 32    /// <summary>
 33    /// Converts the <see cref="DataSet"/> into a first table first column.
 34    /// </summary>
 35    /// <typeparam name="TColumn">The type of the column.</typeparam>
 36    /// <param name="dataSet">The data set.</param>
 37    public static IEnumerable<TColumn> ToFirstTableFirstColumn<TColumn>(this DataSet? dataSet)
 038    {
 039        var rows = dataSet.ToFirstTableDataRows();
 40
 041        return rows.Select(i => (TColumn) i[0]);
 042    }
 43
 44    /// <summary>
 45    /// Converts the <see cref="DataSet"/> into a first table rows.
 46    /// </summary>
 47    /// <param name="dataSet">The data set.</param>
 48    public static IEnumerable<KeyValuePair<string, string>> ToFirstTableRows(this DataSet? dataSet) =>
 049        dataSet.ToFirstTableRows<string, string>();
 50
 51    /// <summary>
 52    /// Converts the <see cref="DataSet"/> into a first table rows.
 53    /// </summary>
 54    /// <typeparam name="TKey">The type of the key.</typeparam>
 55    /// <typeparam name="TValue">The type of the value.</typeparam>
 56    /// <param name="dataSet">The data set.</param>
 57    public static IEnumerable<KeyValuePair<TKey, TValue>> ToFirstTableRows<TKey, TValue>(this DataSet? dataSet)
 058    {
 059        var rows = dataSet.ToFirstTableDataRows();
 60
 061        return rows.Select(i => new KeyValuePair<TKey, TValue>((TKey) i[0], (TValue) i[1]));
 062    }
 63}