I use Dapper-Extentions to pull and push data to database
I use unsigned int
id as my Primary key in database and in the class as well.
my class looks like this
public class Product {
[Column("id")]
public uint Id { get; set; }
}
My Mapper Class looks like this
public class ProductMap : ClassMapper<Product>
{
public ProductMap()
{
Table("Product");
this.Map(typeof(Product).GetProperty("Id")).Key(KeyType.Identity);
}
}
I insert data like this
using DapperExtensions;
public virtual uint Add(T item)
{
using (conn)
{
return Convert.ToUInt32(conn.Insert<T>(item)); // System.ArgumentException: 'Object of type 'System.Int32' cannot be converted to type 'System.UInt32'.'`
}
}
When I insert data into database, the item get inserted into the database without issues, However the Insert function keeps returning the following error :
'Object of type 'System.Int32' cannot be converted to type 'System.UInt32'.'
How can I possibly fix that ?