转换了ToList()抛出异常对象必须实现IConvertible [英] converting toList() throws exception Object must implement IConvertible

查看:2982
本文介绍了转换了ToList()抛出异常对象必须实现IConvertible的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到这个异​​常对象必须实现IConvertible。在转换规则了ToList()。下面是我的code

  VAR规则从M =在db.Rules选择米;
 返回rules.ToList()ToDataTable()。 //这里发生异常

我使用的是MySQL 6.3.6 ..the相同code是工作的罚款与MSSQL。

我会很感激,如果有人可以帮助我在这

问候
Umair <​​/ P>

解决方案

确认源类型转换为目标类型。结果
也许rules.ToList()不匹配您ToDataTable目标施放。

您可以验证哪些 VAR列表= rules.ToList()包含?

和... ...我建议处理列表和IEnumerable对数据表。

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

解决方案

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.

这篇关于转换了ToList()抛出异常对象必须实现IConvertible的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆