且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在MVC中编辑动态创建的数据表/ json

更新时间:2023-12-01 15:00:22

直接使用DataTable无论如何都不是***实践,如果您知道可以创建类并映射字段的所有列,即使您可以使用nuget上可用的newtonsoft,它也会将json数据映射到您的这个。



使用你定义的类,你的代码将变得更容易阅读,你的代码也将变得不那么复杂。



问候,

Santosh
Using DataTable directly is anyways not a best practice, if you are aware of all columns you can create a class and map the fields, even you can use newtonsoft which is available on nuget, it does the mapping of json data to your class.

With your defined class your code will become more easy to read, and your code will also become less complex.

Regards,
Santosh