Reputation: 26517
which senario do you prefer when you're retrieving data from database?
1 - Populating a datatable and then bind a datagridview to it?
OR
2- populating a genric list of your own custom object and then bind a datagridview to it?
Thank you
Upvotes: 2
Views: 308
Reputation: 22485
reasons (or as marc notes, 'merits'):
also, using DataTables directly means tying yourself to the underlying data source and how that is structured. From a maintainability point of view, this isn't a good idea. If all your view needs is a list of some objects, that's all you should be giving it (i.e. a list).
[edit] - it's an old article, but is worth adding to the 'debate':
When considering DataSets vs. business objects, remember that a well designed application using business objects will reduce future headaches in the maintenance of the application which ultimately lead to lower support costs.
http://www.kellermansoftware.com/t-articlebusinessobjects.aspx
Upvotes: 2
Reputation: 11658
I would not suggest working with db directly at all. There're nice ORMs: LINQ to SQL, Entity Framework and NHibernate. Who needs old painful datatables ?
Upvotes: 1