Answers for "Func<IDataRecord, T> c#"

C#
0

Func<IDataRecord, T> c#

public IEnumerable<T> GetData<T>(IDataReader reader, Func<IDataRecord, T> BuildObject)
{
    try
    {
        while (reader.Read())
        {
            yield return BuildObject(reader);
        }
    }
    finally
    {
         reader.Dispose();
    }
}

//call it like this:
var result = GetData(YourLibraryFunction(), Employee.Create);
Posted by: Guest on November-03-2020

C# Answers by Framework

Browse Popular Code Answers by Language