c# - How to get the correct object format when doing ExecuteScalar on a database? -


i have database table different column types, example:

column 1   column 2   column 3   column 4  (string)   (decimal)  (string)   (int) 

i have create class has exact same format, lets call dbtableformat example. doing select in c# using executescalar method of isqldatabase this:

list<dbtableformat> mytable = db.executescalar<list<dbtableformat>>("select * dbtablename  whatever") 
  • db isqldatabase

i expect able list in correct format, instead following error:

unable cast object of type 'system.int32' type 'system.collections.generic.list`1[dbtableformat]'.

why considering int32 , not understanding in conversion? because don't understand completely.


Comments