Faster (more scalable) DataSet.Merge?

后端 未结 5 865
孤街浪徒
孤街浪徒 2021-01-25 11:52

We use strongly typed DataSets in our application. When importing data we use the convenient DataSet.Merge() operation to copy DataRows from one DataSet to another.

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-25 12:31

    You've probably already tried this, but just in case:

    DataSet.Merge takes an array or DataRows as a parameter.

    Have you tried batching the merge, i.e. doing the following?

    dataSet1.Merge(lines.Select(line=>ImportRow(line)).ToArray());
    

    However, it's quite possibly the case that you cannot improve performance - maybe you can avoid the need to Merge in the first place somehow - such as by doing the merge in the DB, as Sklivvz suggests.

提交回复
热议问题