DapperLib / DapperLib/Dapper

The reader has been disposed with version 2.0.123

Open
#1,821 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
18.4k
Forks
3.7k
Avg merge
5h 8m
Merged PRs (30d)
1

Description

Hi i have problem and i was searching on internet but not found the correct answer. Can you tell me how to solve it. When i execute the first result i ok and after that i got the error message "The reader has been disposed; this can happen after all data has been consumed" , i also try .ToList() but the same error occur result.InfozasitePcja = (await res.ReadAsync()).ToList(); Because it is IEnumerable i can not use .ToListAsync(). Here is my code.

public async Task<GetInfoForUserSummary> GetInfoForUser(string column, string search)
{
    GetInfoForUserSummary result = new GetInfoForUserSummary();
    try
    {
        var query = "Select i.*,s.*,u.*,e.* From InfoZaSitePCja i " +
            "INNER JOIN SEPreport s ON i.ComputerName = s.COMPUTER_NAME " +
            "INNER JOIN Users u ON s.CURRENT_LOGIN_USER = u.SamAccountName " +
            "INNER JOIN Eerv e ON u.EmployeeNumber = e.[kadr.br.] " +
            "Where [" + column + "] LIKE '%' + @search + '%'";
        var param = new DynamicParameters();
        param.Add("@search", search, DbType.String);
        var res = await Connection.QueryMultipleAsync(query, param, commandType: CommandType.Text, transaction: Transaction);

        result.InfozasitePcja = await res.ReadAsync<InfozasitePcja>();
        result.SEPreport = await res.ReadAsync<SEPreport>();
        result.Users = await res.ReadAsync<Users>();
        result.Eerv = await res.ReadAsync<Eerv>();
    }
    catch (Exception e)
    {
        _logger.Error(e);
        throw new Exception("Database Error", e);
    }
    return result;
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the GetInfoForUser method in the issue and inspect the QueryMultipleAsync call followed by its four ReadAsync calls. Reproduce the sequence with the shown query and determine which read consumes or disposes the reader; done means the cause and a verified usage correction are documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
18/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.