DataTable 那些事(一)

I don't think many of u have experience with DataTable.Load or DataTable.Merge, so here I take time to write it down for future check and records.

The MSDN document has a good sample and explanation about Load method: http://msdn.microsoft.com/en-us/library/4e06d41f.aspx

Too long for a lazy man to read, hum? Here is the sample running result, which I think can clarify the things up:

One item has a historical original value and a current value.

LoadOption.OverwriteChanges option means to overwrite both//全部覆盖
LoadOption.PreserveChanges option means to overwrite unchanged current value and original value//覆盖未改变的最新值和所有原始值
LoadOption.Upsert option means to overwrite undeleted current value and keep original value//覆盖未删除的最新值,保留原始值

I guess Load method internally calls Merge method.

If you want to append a DataTable to another, you'd use DataTable.Rows.Add method, instead.

原文地址:https://www.cnblogs.com/feishunji/p/1923220.html