internal static async Task <List <T> > ToListAsync <T>([NotNull] this DbCommand command, MappingManager mapper) where T : class, new()
        {
            var list = new List <T>();

            using (command)
            {
                if ((command.Connection.State & ConnectionState.Open) == 0)
                {
                    command.Connection.Open();
                }

                using (var reader = await command.ExecuteReaderAsync())
                {
                    var map = mapper.GetSpMappingFor <T>(reader, command.CommandText);
                    while (reader.Read())
                    {
                        var obj = new T();
                        map(reader, obj);
                        list.Add(obj);
                    }
                }
            }
            return(list);
        }
        internal static async Task <T> FirstOrDefault <T>([NotNull] this DbCommand command, MappingManager mapper) where T : class, new()
        {
            using (command)
            {
                if ((command.Connection.State & ConnectionState.Open) == 0)
                {
                    command.Connection.Open();
                }

                using (var reader = await command.ExecuteReaderAsync())
                {
                    if (reader.Read())
                    {
                        var map = mapper.GetSpMappingFor <T>(reader, command.CommandText);
                        var obj = new T();
                        map(reader, obj);
                        return(obj);
                    }
                }
            }
            return(null);
        }