using EasyDevCore.Database.EntityFrameworkCore;
using EasyDevCore.Common;
using Microsoft.EntityFrameworkCore.Storage;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using EasyDev.Database;
namespace EasyDevCore.Database.EntityFrameworkCore
{
///
///
///
public static class RelationalDataReaderExtensions
{
///
/// Gets the value.
///
///
/// The reader.
/// Name of the field.
/// The value if null.
///
public static T GetValue(this RelationalDataReader reader, string fieldName, T valueIfNull) => reader.DbDataReader.GetValue(fieldName, valueIfNull);
///
/// Gets the row.
///
/// The reader.
///
public static dynamic GetRow(this RelationalDataReader reader) => reader.DbDataReader.GetRow();
///
/// Gets the row asynchronous.
///
/// The reader.
/// The cancellation token.
///
public static Task GetRowAsync(this RelationalDataReader reader, CancellationToken cancellationToken)
=> reader.DbDataReader.GetRowAsync(cancellationToken);
///
/// Fetches to dynamic.
///
/// The reader.
///
public static IList FetchToDynamic(this RelationalDataReader reader) => reader.DbDataReader.FetchToDynamic();
///
/// Fetches to dynamic asynchronous.
///
/// The reader.
/// The cancellation token.
///
public static Task> FetchToDynamicAsync(this RelationalDataReader reader, CancellationToken cancellationToken = default)
=> reader.DbDataReader.FetchToDynamicAsync(cancellationToken);
///
/// Fetches the fill list.
///
///
/// The reader.
/// The list.
///
public static int FetchFillList(this RelationalDataReader reader, IList list) where T : class, new() => reader.DbDataReader.FetchFillList(list);
///
/// Fetches the fill list asynchronous.
///
///
/// The reader.
/// The list.
/// The cancellation token.
///
public static Task FetchFillListAsync(this RelationalDataReader reader, IList list, CancellationToken cancellationToken = default)
where T : class, new() => reader.DbDataReader.FetchFillListAsync(list, cancellationToken);
///
/// Fetches to list.
///
/// The type of the result.
/// The reader.
/// The selector.
///
public static IList FetchToList(this RelationalDataReader reader, Func selector) => reader.DbDataReader.FetchToList(selector);
///
/// Fetches to list asynchronous.
///
/// The type of the result.
/// The reader.
/// The selector.
/// The cancellation token.
///
public static Task> FetchToListAsync(this RelationalDataReader reader, Func selector, CancellationToken cancellationToken = default)
=> reader.DbDataReader.FetchToListAsync(selector, cancellationToken);
///
/// Fetches to list.
///
///
/// The reader.
/// The list.
///
public static IList FetchToList(this RelationalDataReader reader, IList list = null) where T : class, new() => reader.DbDataReader.FetchToList(list);
///
/// Fetches to list asynchronous.
///
///
/// The reader.
/// The list.
/// The cancellation token.
///
public static Task> FetchToListAsync(this RelationalDataReader reader, IList list = null, CancellationToken cancellationToken = default)
where T : class, new() => reader.DbDataReader.FetchToListAsync(list, cancellationToken);
///
/// Fetches the fill data set.
///
/// The reader.
/// The data set.
public static int FetchFillDataSet(this RelationalDataReader reader, DataSet dataSet) => reader.DbDataReader.FetchFillDataSet(dataSet);
///
/// Fetches the fill data set asynchronous.
///
/// The reader.
/// The data set.
/// The cancellation token.
///
public static Task FetchFillDataSetAsync(this RelationalDataReader reader, DataSet dataSet, CancellationToken cancellationToken = default)
=> reader.DbDataReader.FetchFillDataSetAsync(dataSet, cancellationToken);
//
///
/// Fetches to data set.
///
/// The reader.
/// The data set.
/// The parameters.
///
public static DataSet FetchToDataSet(this RelationalDataReader reader, DataSet dataSet = null, EasyDbParameterCollection parameters = null) => reader.DbDataReader.FetchToDataSet(dataSet, parameters);
///
/// Fetches to data set asynchronous.
///
/// The reader.
/// The entity set.
/// The cancellation token.
///
public static Task FetchToDataSetAsync(this RelationalDataReader reader, DataSet DataSet = null, CancellationToken cancellationToken = default)
=> reader.DbDataReader.FetchToDataSetAsync(DataSet, cancellationToken);
///
/// Fetches to table.
///
/// The reader.
/// The table.
///
public static int FetchFillTable(this RelationalDataReader reader, DataTable table) => reader.DbDataReader.FetchFillTable(table);
///
/// Fetches to table.
///
/// The reader.
/// The table.
/// The cancellation token.
///
public static Task FetchFillTableAsync(this RelationalDataReader reader, DataTable table, CancellationToken cancellationToken = default)
=> reader.DbDataReader.FetchFillTableAsync(table, cancellationToken);
///
/// Fetches to table.
///
/// The reader.
/// The table.
///
public static DataTable FetchToTable(this RelationalDataReader reader, DataTable table = null) => reader.DbDataReader.FetchToTable(table);
///
/// Fetches to table asynchronous.
///
/// The reader.
/// The table.
/// The cancellation token.
///
public static Task FetchToTableAsync(this RelationalDataReader reader, DataTable table = null, CancellationToken cancellationToken = default)
=> reader.DbDataReader.FetchToTableAsync(table, cancellationToken);
}
}