The exception that am recieving is clear. i did use dapper before and it worked great but now am having hard time.
Unable to cast object of type 'System.Func2[System.Data.IDataReader,WebApplication1.Modal.Users]' to type 'System.Func
2[System.Data.IDataReader,System.Object]'.
User Class is
public class Users : MainSharedTable
{
public int FkReceiverID { get; set; }
public string Password { get; set; }
}
MainSharedTable is
public class MainSharedTable
{
public int ID { get; set; }
public bool Active { get; set; }
}
and the exception happens here
public IEnumerable<Users> GetAll()
{
var conn = GetOpenConnection();
var data = conn.Query<Users>("SELECT * FROM arabaicsms.users "); // error happens here
ConnectionClose();
return data;
}
any help is appreciated note: my db is MYSQL and if do not cast the returned object i receive a dictionary
full stack
[InvalidCastException: Unable to cast object of type 'System.Func`2[System.Data.IDataReader,WebApplication1.Modal.Users]' to type 'System.Func`2[System.Data.IDataReader,System.Object]'.]
Dapper.SqlMapper.GetTypeDeserializerImpl(Type type, IDataReader reader, Int32 startBound, Int32 length, Boolean returnNullIfFirstMissing) +10454
Dapper.TypeDeserializerCache.GetReader(IDataReader reader, Int32 startBound, Int32 length, Boolean returnNullIfFirstMissing) +412
Dapper.TypeDeserializerCache.GetReader(Type type, IDataReader reader, Int32 startBound, Int32 length, Boolean returnNullIfFirstMissing) +379
Dapper.SqlMapper.GetTypeDeserializer(Type type, IDataReader reader, Int32 startBound, Int32 length, Boolean returnNullIfFirstMissing) +72
Dapper.SqlMapper.GetDeserializer(Type type, IDataReader reader, Int32 startBound, Int32 length, Boolean returnNullIfFirstMissing) +520
Dapper.<QueryImpl>d__58`1.MoveNext() +1293
System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +387
System.Linq.Enumerable.ToList(IEnumerable`1 source) +119
Dapper.SqlMapper.Query(IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable`1 commandTimeout, Nullable`1 commandType) +787
WebApplication1.BL.UsersBs.GetAll() in C:\Users\pc\documents\visual studio 2015\Projects\ArabaicSmsWeb\WebApplication1\BL\UsersBs.cs:25
WebApplication1.login.Page_Load(Object sender, EventArgs e) in C:\Users\pc\documents\visual studio 2015\Projects\ArabaicSmsWeb\WebApplication1\login.aspx.cs:17
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +95
System.Web.UI.Control.LoadRecursive() +59
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +780
the table at the database is like below
there is nothing strange around, i did even capitalize the table latter and make them small also but the same error is there