How can I use a dataset in Automapper?

回眸只為那壹抹淺笑 提交于 2019-12-04 12:51:08

I want to use the dataset instead of the datareader so I dont keep the connection to the database open.

I think I have found the solution;

  1. Create the dataset and close/dispose the connection
  2. create a datatablereader from the datatable and pass the in

This seems to be working.

 DataTableReader dataTableReader = ds.Tables[0].CreateDataReader();
                conn101.Close();
                conn101.Dispose();


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