Data Adapter Vs Sql Command

随声附和 提交于 2019-11-28 10:23:10
Muhammad Akhtar

Updating a data source is much easier using DataAdapters. It's easier to make changes since you just have to modify the DataSet and call Update.

There is probably no (or very little) difference in the performance between using DataAdapters vs Commands. DataAdapters internally use Connection and Command objects and execute the Commands to perform the actions (such as Fill and Update) that you tell them to do, so it's pretty much the same as using only Command objects.

I would use LinqToSql with a DataSet for single insert and most Database CRUD requests. It is type safe, relatively fast for non compilcated queries such as the one above.

If you have many rows to insert (1000+) and you are using SQL Server 2008 I would use SqlBulkCopy. You can use your DataSet and input into a stored procedure and merge into your destination

For complicated queries I recommend using dapper in conjunction with stored procedures.

I suggest you would have some kind of control on your communication with the database. That means abstracting some code, and for that the CommandBuilder automatically generates CUD statements for you.

What would be even better is if you use that technique together with a typed Dataset. then you have intellisense and compile time check on all your columns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!