1

So I have a pretty simple reader, which executes given query:

            connection.Open();
            using (var r = command.ExecuteReader())
            {
                while (r.Read())
                {
                    foreach (var item in r)
                    {
                        var listOfValues = (System.Data.Common.DbDataRecord)item;
                        result.Add(VisualTsTableMapper.MapFromDbRecord(listOfValues));
                    }
                };
            }
            connection.Close();

As from database, I am getting 4 rows of results. Although after reading I retrieve only 3. What do I do wrong? enter image description here

enter image description here

3
  • 3
    Either enumerate the data reader, or use a loop with .Read() (or better yet, eliminate this boilerplate altogether and use Dapper). Enumeration implicitly starts off with a .Read(), so you're discarding the first row. Commented Jul 19, 2022 at 11:08
  • @JeroenMostert Is Dapper capable of executing PostgreSQL custom functions? Commented Jul 19, 2022 at 11:11
  • Dapper is a lightweight wrapper around ADO.NET, and Npgsql is an ADO.NET driver. If your function access can be written as a query, it will work. The Npgsql docs show nothing special here (except for not having proper support for CommandType.StoredProcedure, apparently); use SELECT/CALL as appropriate. Commented Jul 19, 2022 at 11:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.