Updating many rows at a time in a DataTable
Posted: (EET/GMT+2)
Need to do a fast bulk update to a .NET DataTable class from C#, but don't want to get bothered by connected data update events, etc.? Well, of course you could first eliminate all events from the DataTable, then update your data, and then restore the event handlers, but that seems like a lot of work.
Luckily, there's already a solution to this built into the DataTable class. This is a seldomly-known method called BeginLoadData, which according to the documentation, "turns off notifications, index maintenance, and constraints while loading data." That is, just what you are after!
Of course, there's also the corresponding EndLoadData method, which you must remeber to call once you are done with the update.