使用C#将DataSet转换为通用列表 [英] Converting DataSet to Generic List using C#

查看:76
本文介绍了使用C#将DataSet转换为通用列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有数据集。当我试图将数据表转换为通用列表系统时,由于数据表超过5000行而导致操作超时错误。

请帮助我们快速将批量数据行转换为列表。



Hi,

I am having the Dataset. When i have tried to convert the datatable to generic list systtem rasised the Opereation Time Out error because of the the datatable having more than 5000 rows.
Kindly help us to convert the bulk datarows to the list fastly.

private List<EventUpdation> GetListByDataTable(DataSet dt, string entryType)
       {




List<EventUpdation> result = (from reader in dt.Tables[0].AsEnumerable()
                                          select new EventUpdation()
                                          {



ID = Utility.ToLong(读者[event_pid]),





.//100要保护的属性







返回结果;

}

}


ID = Utility.ToLong(reader["event_pid"]),
.
.
.//100 properties to be assined
.
.

return result;
}
}

推荐答案

尝试老式循环:



Try "old fashioned" loop:

foreach (DataRow dr in dt.Tables[0].Rows)
{
   //..update your collection element here
}





但我怀疑问题在于数据本身。数据来自数据库吗?您是否检查过数据库查询在代码之外的执行情况?更多细节,您将获得更好的答案。



But my suspicion is that problem is in the data itself. Is data coming from the database? Did you check how database query is performing outside of your code? More details you provide better answers you will get.


这篇关于使用C#将DataSet转换为通用列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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