<p>I've found myself increasingly unsatisfied with the DataSet/DataTable/DataRow paradigm in .Net, mostly because it's often a couple of steps more complicated than what I really want to do.  In cases where I'm binding to controls, DataSets are fine.  But in other cases, there seems to be a fair amount of mental overhead.</p>

<p>I've played a bit with SqlDataReader, and that seems to be good for simple jaunts through a select, but I feel like there may be some other models lurking in .Net that are useful to learn more about.  I feel like all of the help I find on this just uses DataSet by default.  Maybe that and DataReader really are the best options.</p>

<p>I'm not looking for a best/worst breakdown, just curious what my options are and what experiences you've had with them.  Thanks!</p>

<p>-Eric Sipple</p>

[{'answer_id': 18539, 'author': 'TheSmurf', 'author_id': 1975282, 'author_profile': 'https://Stackoverflow.com/users/1975282', 'pm_score': 5, 'selected': True, 'text': "<p>Since .NET 3.5 came out, I've exclusively used LINQ. It's really that good; I don't see any reason to use any of those old crutches any more. </p>\n\n<p>As great as LINQ is, though, I think any ORM system would allow you to do away with that dreck.</p>\n"}, {'answer_id': 18546, 'author': 'hometoast', 'author_id': 2009, 'author_profile': 'https://Stackoverflow.com/users/2009', 'pm_score': 2, 'selected': False, 'text': '<p>We\'ve moved away from datasets and built our own ORM objects loosely based on <a href="http://www.lhotka.net" rel="nofollow noreferrer">CSLA</a>.  You can get the same job done with either a DataSet or LINQ or ORM but re-using it is (we\'ve found) a lot easier.  \'Less code make more happy\'.</p>\n'}, {'answer_id': 18555, 'author': 'Eric Z Beard', 'author_id': 1219, 'author_profile': 'https://Stackoverflow.com/users/1219', 'pm_score': 1, 'selected': False, 'text': '<p>I use them extensively but I don\'t make use of any of the "advanced" features that Microsoft was really pushing when the framework first came out.  I\'m basically just using them as Lists of Hashtables, which I find perfectly useful.</p>\n\n<p>I have not seen good results when people have tried to make complex typed DataSets, or tried to actually set up the foreign key relationships between tables with DataSets.</p>\n\n<p>Of course, I am one of the weird ones that actually prefers a DataRow to an entity object instance.</p>\n'}, {'answer_id': 18574, 'author': 'JamesSugrue', 'author_id': 1075, 'author_profile': 'https://Stackoverflow.com/users/1075', 'pm_score': 1, 'selected': False, 'text': '<p>Pre linq I used DataReader to fill List of my own custom domain objects, but post linq I have been using L2S to fill L2S entities, or L2S to fill domain objects.</p>\n\n<p>Once I get a bit more time to investigate I suspect that Entity Framework objects will be my new favourite solution!</p>\n'}, {'answer_id': 18581, 'author': 'Keith', 'author_id': 905, 'author_profile': 'https://Stackoverflow.com/users/905', 'pm_score': 2, 'selected': False, 'text': "<p>I was fed up with DataSets in .Net 1.1, at least they optimised it so that it doesn't slow as exponentially for large sets any more.</p>\n\n<p>It was always a rather bloated model - I haven't seen many apps that use most of its features.</p>\n\n<p>SqlDataReader was good, but I used to wrap it in an <code>IEnumerable&lt;T&gt;</code> where the T was some typed representation of my data row.</p>\n\n<p>Linq is a far better replacement in my opinion. </p>\n"}, {'answer_id': 18630, 'author': 'Mike', 'author_id': 785, 'author_profile': 'https://Stackoverflow.com/users/785', 'pm_score': 0, 'selected': False, 'text': "<p>I just build my business objects from scratch, and almost never use the <code>DataTable</code> and especially not the <code>DataSet</code> anymore, except to initially populate the business objects.  The advantages to building your own are testability, type safety and IntelliSense, extensibility (try adding to a <code>DataSet</code>) and readability (unless you enjoy reading things like <code>Convert.ToDecimal(dt.Rows[i][&quot;blah&quot;].ToString())</code>).</p>\n<p>If I were smarter I'd also use an ORM and 3rd party DI framework, but just haven't yet felt the need for those.  I'm doing lots of smaller size projects or additions to larger projects.</p>\n"}, {'answer_id': 18908, 'author': 'Brian Leahy', 'author_id': 580, 'author_profile': 'https://Stackoverflow.com/users/580', 'pm_score': 2, 'selected': False, 'text': "<p>DataSets are great for demos.</p>\n\n<p>I wouldn't know what to do with one if you made me use it.</p>\n\n<p>I use ObservableCollection</p>\n\n<p>Then again i'm in the client app space, WPF and Silverlight.  So passing a dataset or datatable through a service is ... gross.</p>\n\n<p>DataReaders are fast, since they are a forward only stream of the result set.</p>\n"}, {'answer_id': 19270, 'author': 'bakasan', 'author_id': 2228, 'author_profile': 'https://Stackoverflow.com/users/2228', 'pm_score': 1, 'selected': False, 'text': "<p>Selecting a modern, stable, and actively supported ORM tool has to be probably the single biggest boost to productivity just about any project of moderate size and complexity can get.  If you're concluding that you absolutely, absolutely, absolutely have to write your own DAL and ORM, you're probably doing it wrong (or you're using the world's most obscure database).  </p>\n\n<p>If you're doing raw datasets and rows and what not, spend the day to try an ORM and you'll be amazed at how much more productive you can be w/o all the drudgery of mapping columns to fields or all the time filling Sql command objects and all the other hoop jumping we all once went through.</p>\n\n<p>I love me some Subsonic, though for smaller scale projects along with demos/prototypes, I find Linq to Sql pretty damn useful too.  I hate EF with a passion though. :P</p>\n"}, {'answer_id': 23308, 'author': 'Jesse Taber', 'author_id': 1680, 'author_profile': 'https://Stackoverflow.com/users/1680', 'pm_score': 2, 'selected': False, 'text': '<p>I\'ve been using the <a href="http://en.wikipedia.org/wiki/Data_Transfer_Object" rel="nofollow noreferrer">Data Transfer Objects</a> pattern (originally from the Java world, I believe), with a SqDataReader to populate collections of DTOs from the data layer for use in other layers of the application.\nThe DTOs themselves are very lightweight and simple classes composed of properties with gets/sets. They can be easily serialized/deserialized, and used for databinding, making them pretty well suited to most of my development needs.</p>\n'}, {'answer_id': 103359, 'author': 'fuzzbone', 'author_id': 5027, 'author_profile': 'https://Stackoverflow.com/users/5027', 'pm_score': -1, 'selected': False, 'text': '<p>I NEVER use datasets.  They are big heavyweight objects only usable (as someone pointed out here) for "demoware".  There are lot\'s of great alternatives shown here.</p>\n'}, {'answer_id': 103414, 'author': 'John Rudy', 'author_id': 14048, 'author_profile': 'https://Stackoverflow.com/users/14048', 'pm_score': 2, 'selected': False, 'text': '<p>I\'m a huge fan of <a href="http://subsonicproject.com/" rel="nofollow noreferrer">SubSonic</a>. A well-written batch/CMD file can generate an entire object model for your database in minutes; you can compile it into its own DLL and use it as needed. Wonderful model, wonderful tool. The site makes it sound like an ASP.NET deal, but generally speaking it works wonderfully just about anywhere if you\'re not trying to use its UI framework (which I\'m moderately disappointed in) or its application-level auto-generation tools.</p>\n\n<p>For the record, here is a version of the command I use to work with it (so that you don\'t have to fight it too hard initially):</p>\n\n<pre><code>sonic.exe generate /server [servername] /db [dbname] /out [outputPathForCSfiles] /generatedNamespace [myNamespace] /useSPs true /removeUnderscores true\n</code></pre>\n\n<p>That does it every time ... Then build the DLL off that directory -- this is part of an NAnt project, fired off by CruiseControl.NET -- and away we go. I\'m using that in WinForms, ASP.NET, even some command-line utils. This generates the fewest dependencies and the greatest "portability" (between related projects, EG).</p>\n\n<p><strong>Note</strong></p>\n\n<p>The above is now well over a year old. While I still hold great fondness in my heart for SubSonic, I have moved on to LINQ-to-SQL when I have the luxury of working in .NET 3.5. In .NET 2.0, I still use SubSonic. So my new official advice is platform version-dependent. In case of .NET 3+, go with the accepted answer. In case of .NET 2.0, go with SubSonic.</p>\n'}, {'answer_id': 1766372, 'author': 'Ryan Lundy', 'author_id': 5486, 'author_profile': 'https://Stackoverflow.com/users/5486', 'pm_score': 1, 'selected': False, 'text': '<p>I\'ve used typed DataSets for several projects.  They model the database well, enforce constraints on the client side, and in general are a solid data access technology, especially with the changes in .NET 2.0 with TableAdapters.</p>\n\n<p>Typed DataSets get a bad rap from people who like to use emotive words like "bloated" to describe them.  I\'ll grant that I like using a good O/R mapper more than using DataSets; it just "feels" better to use objects and collections instead of typed DataTables, DataRows, etc.  But what I\'ve found is that if for whatever reason you can\'t or don\'t want to use an O/R mapper, typed DataSets are a good solid choice that are easy enough to use and will get you 90% of the benefits of an O/R mapper.</p>\n\n<p><strong>EDIT:</strong></p>\n\n<p>Some here suggest that DataReaders are the "fast" alternative.  But if you use Reflector to look at the internals of a DataAdapter (which DataTables are filled by), you\'ll see that it uses...a DataReader.  Typed DataSets <em>may</em> have a larger memory footprint than other options, but I\'ve yet to see the application where this makes a tangible difference.</p>\n\n<p>Use the best tool for the job.  Don\'t make your decision on the basis of emotive words like "gross" or "bloated" which have no factual basis.</p>\n'}, {'answer_id': 7628271, 'author': 'JimmyJame', 'author_id': 975676, 'author_profile': 'https://Stackoverflow.com/users/975676', 'pm_score': 2, 'selected': False, 'text': '<p>I have used typed and untyped DataSets, DataViewManagers, DataViews, DataTables, DataRows, DataRowViews, and just about anything you can do with the stack since it firsts came out in multiple enterprise projects.  It took me awhile to get used to how allow of it worked.  I have written custom components that leverage the stack as ADO.NETdid not quite give me what I really needed.  One such component compares DataSets and then updates backend stores.  I really know how all of these items work well and those that have seen what I have done are very impressed that I managed to get beyond there feel that it was only useful for demo use. </p>\n\n<p>I use ADO.NET binding in Winforms and I also use the code in console apps.  I most recently have teamed with another developer to create a custom ORM that we used against a crazy datamodel that we were given from contractors that looked nothing like our normal data stores.</p>\n\n<p>I searched today for replacement to ADO.NET and I do not see anything that I should seriously try to learn to replace what I currently use.</p>\n'}]
['https://Stackoverflow.com/questions/18533', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/111/']