我有一个 IEnumerable,我想做一个批量插入(240,000+ 条记录)。我一直在阅读论坛和 SO,但我无法想出一些可行的东西......
另一个问题是我需要能够指定不同的提供者,因为这些记录需要插入到具有不同连接字符串的数据库中。
基本上,是这样的:
IEnumerable<MyObject> records = GetRecords();
SubSonicDooHickey.BatchSave(records, "differentSubsonicProvider")
我知道这并不准确,但类似的东西......
我试过了:
var itemsToSaveCollection = new ItemCollection(); // Your collection type here
foreach (var xmlItem in xmlItems)
{
var item = new Item(); // Your data model type here
// Set item values from xml
itemsToSaveCollection.Add(item);
}
itemsToSaveCollection.BatchSave();
(和其他几个)但无法让它们工作......上面的代码不起作用,因为我无法从 subsonic 找到一个合适的集合,它有一个.BatchSave
功能,我也不知道如何更改提供者。