DataTable instead of Entity framework in Asp.Net MVC

前端 未结 2 1014
无人及你
无人及你 2021-01-03 12:49

How do I use Datatable instead of Entity framework in Asp.Net mvc?

I\'m referring to this tutorial on the asp.net Website .... http://www.asp.net/Learn/mvc/tutorial-

2条回答
  •  自闭症患者
    2021-01-03 13:31

    If I understand your question correctly, just because you are using MVC you do not have to use Entity framework to communicate with the database.

    Inside your controller you can use whatever means you want to get the data out of the database. Then you can either transform that data into a custom object which you pass to your View, or you could potentially just pass a DataTable to your view.

    Your view just has to know how to iterate through your object that you pass to it.

    However, I recommend using POCO objects to pass to your view, so that you don't tightly couple your view data to the technology used to extract information from the database.

提交回复
热议问题