any one can explain with an example why passing POCO's is better than datatable? with data table you do not need to worry about null values or datatatype
1 Answers
Basically the idea is that the ViewModel (POCO) is tailored exactly to the needs of the View. It should only contain the data that needs to be displayed. It also serves as an interface to decouple the View from the data store. Frontend concerns like defining labels for the data and input validation can also be implemented cleanly by the ViewModel.
Consider an use case where you have to display data that is stored across multiple tables in the database. E.g. "My recent orders" page must display data from Users, Orders, OrderLines, Products, etc. tables. On the other hand, we do not need all columns from these tables (e.g. internal price of a product should not be shown to the customer).
If you just expose the datatables directly, you will transport much to much information compared to what is needed. Also, any changes to the data model will directly influence your view. But you want to decouple the data storage from the display aspects.
Further reading:

- 9,357
- 1
- 26
- 36