Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>While I would also like to suggest ORM (NHibernate is the way to go:)) a possible solution is:</p> <pre><code>public IEnumerable&lt;Report&gt; ToReportList(DataTable dt) { return dt.AsEnumerable().Select(dr =&gt; new Report { member1 = dr["column1"].ToString(), ... }); } </code></pre> <p>Report is your class here by the way.Such as,</p> <pre><code>internal class Report { public string member1{ get; set;} ... } </code></pre> <p>You may also want to check this,</p> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/Bb399375(v=VS.100).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/Bb399375(v=VS.100).aspx</a></li> </ul> <p>I think if you search stackoverflow, you will find nicer examples as I remember learning this from here.</p> <p>By the way, if you use NHibernate, you won't have to rewrite your queries at all. All you have to do is map your tables to a class and booya you are good to go. It will handle all your DML stuff (well mostly) and you can easily tell the ORM to do LazyLoad, Batch processing etc which is pretty cool.</p> <blockquote> <p>Super bonus points if there is an easy way of going backwards (updating the database if the objects are changed).</p> </blockquote> <p>For that , go for ORM i.e. NHibernate (I know I am biased :)). For LINQ to SQL examples check the 2 links below:</p> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/bb386931.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb386931.aspx</a></li> <li><a href="http://csainty.blogspot.com/2008/01/linq-to-sql-insertupdatedelete.html" rel="nofollow noreferrer">http://csainty.blogspot.com/2008/01/linq-to-sql-insertupdatedelete.html</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload