You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
System.InvalidCastException:Error parsing column 0 (id='a-char-type-value-in-datebase' - Object)
in /_/Dapper/SqlMapper.cs:line 3928
at Dapper.SqlMapper.ThrowDataException(Exception ex, Int32 index, IDataReader reader, Object value)
at Deserialize8cb9bee9-c2a8-4fec-bfdc-167531fec084(DbDataReader)
This is example:
public class user
{
public string id {get;set;} // char(36) in db
public int age {get;set;} // int in db
}
SELECT * FROM user WHERE true ORDER BY age ; =>this is OK !
SELECT * FROM user WHERE true ORDER BY age ASC ; =>this is Throw InvalidCastException !
SELECT * FROM user WHERE true ORDER BY age DESC ; =>this is Throw InvalidCastException !
Change the type of the id-column in mysql : char(36) → varchar(36) , then :
SELECT * FROM user WHERE true ORDER BY age ; =>this is OK !
SELECT * FROM user WHERE true ORDER BY age ASC ; =>this is OK !
SELECT * FROM user WHERE true ORDER BY age DESC ; =>this is OK !
The text was updated successfully, but these errors were encountered:
System.InvalidCastException:Error parsing column 0 (id='a-char-type-value-in-datebase' - Object)
in /_/Dapper/SqlMapper.cs:line 3928
at Dapper.SqlMapper.ThrowDataException(Exception ex, Int32 index, IDataReader reader, Object value)
at Deserialize8cb9bee9-c2a8-4fec-bfdc-167531fec084(DbDataReader)
This is example:
public class user
{
public string id {get;set;} // char(36) in db
public int age {get;set;} // int in db
}
SELECT * FROM user WHERE true ORDER BY age ; =>this is OK !
SELECT * FROM user WHERE true ORDER BY age ASC ; =>this is Throw InvalidCastException !
SELECT * FROM user WHERE true ORDER BY age DESC ; =>this is Throw InvalidCastException !
Change the type of the
id
-column in mysql : char(36) → varchar(36) , then :SELECT * FROM user WHERE true ORDER BY age ; =>this is OK !
SELECT * FROM user WHERE true ORDER BY age ASC ; =>this is OK !
SELECT * FROM user WHERE true ORDER BY age DESC ; =>this is OK !
The text was updated successfully, but these errors were encountered: