converting toList() throws exception Object must implement IConvertible

安稳与你 提交于 2020-01-03 05:19:48

问题


I am getting this exception "Object must implement IConvertible." while converting rules to tolist(). below is my code

var rules = from m in db.Rules select m;
 return rules.ToList().ToDataTable(); // exception occurs here

I am using MySQL 6.3.6 ..the same code is working fine with MSSQL.

I will be grateful if someone helps me in this

regards Umair


回答1:


Make sure the source type is convertible to the destination type.
Probably the rules.ToList() don't match with you ToDataTable destination cast.

Can you verify what var list = rules.ToList() contains?

And... I suggest deal with List and IEnumerable against Datatable.



来源:https://stackoverflow.com/questions/5741048/converting-tolist-throws-exception-object-must-implement-iconvertible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!