question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use of DataTimeOffset means you must use SqlDataReader

See original GitHub issue

Dapper returns an IDataReader on it’s extension method on top of the SqlConnection. Unfortunately, this does not contain the GetDateTimeOffset member that SqlDataReader does, so the generated SqlHydra code does not work.

Is there an alternative for the use of this member that would work with an IDataReader?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
JordanMarrcommented, Nov 20, 2021

Interesting… Apparently the Dapper crew wrapped it in an extra layer, so I had to do this:

let getProductsWithThumbnailDapper(conn: SqlConnection) = task {
    use wrappedReader = conn.ExecuteReader("SELECT TOP 2 * FROM SalesLT.Product p WHERE ThumbNailPhoto IS NOT NULL")
    use reader = (wrappedReader :?> IWrappedDataReader).Reader :?> SqlDataReader
    let hydraReader = SalesLT.HydraReader(reader)
    return [ 
        while reader.Read() do
            hydraReader.Product.Read() 
    ]
}
0reactions
isaacabrahamcommented, Nov 24, 2021

Perfect, thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Reading a date using DataReader
Try as given below: while (MyReader.Read()) { TextBox1.Text = Convert.ToDateTime(MyReader["DateField"]).ToString("dd/MM/yyyy"); }.
Read more >
SqlDataReader Class (System.Data.SqlClient)
Provides a way of reading a forward-only stream of rows from a SQL Server database. This class cannot be inherited.
Read more >
SqlDataReader.GetSqlDateTime does not support ...
Describe the bug It seems like DATETIME2 sql server datatype is not fully or correctly implemented in SqlDataReader. using method ...
Read more >
UTC gotchas in .NET and SQL Server - Derek says:
Any datetime values retrieved through the SqlDataReader will be an “unspecified” kind DateTime. This means that, even if you're correctly using ...
Read more >
How to read DateTimeOffset from OracleObject
We have reproduced the issue when the object field of the Oracle type TIMESTAMP(6) WITH TIME ZONE returns as System.DateTime. We will ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found