Create Asynchronous (async) method using C# in .Net

Last Reply 3 months ago By dharmendr

Posted 3 months ago

I am trying to make this code async. I was not successful. Please guide me, how to make this method async.

public IEnumerable<T> Read<T>(string sql, Func<IDataReader, T> make, params object[] parms)
{
    using (var connection = CreateConnection())
    {
        using (var command = CreateCommand(sql, connection, parms))
        {
            using (var reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    yield return make(reader);
                }
            }
        }
    }
}