DataTable to Object collection

Posted by Kenneth Cochran on Stack Overflow See other posts from Stack Overflow or by Kenneth Cochran
Published on 2010-03-29T15:51:01Z Indexed on 2010/03/29 15:53 UTC
Read the original article Hit count: 402

Filed under:
|
|
|

I'm working on a data import feature and I've been able to load an excel sheet into a DataTable using Ado.NET with the MSJet db engine. I created a simple one-to-one mapping dialog, in which the user drags column headings from their spreadsheet to a list of object properties.

What's stumping me is how to turn each DataRow into a business object. Is there an easy way to do this?

If there is a better way than using a DataTable as a middleman I'm open to suggestion? I use NHibernate extensively through out the rest of my program but I couldn't find any attempts to map to an excel spreadsheet. I went with a DataTable because the technique was well documented.

© Stack Overflow or respective owner

Related posts about c#

Related posts about datatable