-2

I have the following code:

  using (SqlConnection conn = new SqlConnection(connString))
  {
      conn.Open();
      var datan = conn.Query<SodraCell>("SELECT Name FROM dw_datamarts_Sodra_Nyckeltal.dbo.KeyValues WHERE Company=@company", new { company = "Company1" }).FirstOrDefault();
  }

When I run this, I get an exception saying:

Arithmetic operation resulted in an overflow.

I don't know why. Why do I get this when I'm doing a query like this?

Here is my Model SodraCell:

 public class SodraCell
    {
        public string Name { get; set; }
    }
halfer
  • 19,824
  • 17
  • 99
  • 186
Bryan
  • 3,421
  • 8
  • 37
  • 77

1 Answers1

0

I think that you map your select to 'SodraCell' class. In select your get 'Name' filed, but in class 'SodraCell' your have other fields.

Andrey Ravkov
  • 1,268
  • 12
  • 21
  • No, I only have the property Name in SodraCell. – Bryan Jun 29 '17 at 08:03
  • try to use string. var datan = conn.Query("SELECT Name FROM dw_datamarts_Sodra_Nyckeltal.dbo.KeyValues WHERE Company=@company", new { company = "Company1" }).FirstOrDefault(); double check that column 'Name' is exist in db 'dw_datamarts_Sodra_Nyckeltal.dbo.KeyValues'. may be you column is 'name' in db? i think that exception is not in this peace of code – Andrey Ravkov Jun 29 '17 at 08:10