Asp.net, c#, vs2008, sqlserver 2005.
I am filling a DataTable in the data access layer with data from a sqlserver stored procedure.
Best Practices Question –
Is it ok to pass the DataTable to the business layer and use the DataTable from the business layer for an ObjectDataSource in the presentation layer,
or
Should I transfer the data in the data table into a List and use the List for an ObjectDataSource in the presentation layer?
If I should transfer the data to a List, should that be done in the data access layer or the business layer?
Does it make a difference if the data needs to be edited before being displayed?
My opinion:
It’s OK to use DataTable in the UI, a GridView and other controls can be binded easily to its data through an ObjectDataSource, and paging and sorting is automagic. Paging and sorting must be programmed if you bind to a IList.
It’s NOT OK to use DataTable in the Business Layer, the previous “layer” should transform the DataTable in a domain object. The Business Layer should talk to Orders, not OrdersDataTable.
The creation of the DataTable should be, for example, a UI responsability, not a Business responsability.
Totally, you should use a “Service Layer” to wrap the “Business Layer”.