使用 subsonic 2.2 批量插入到不同的提供商
我有一个 IEnumerable,我想批量插入(240,000 多条记录)。我一直在仔细阅读论坛,所以我一直无法想出一些有用的东西...
另一个问题是我需要能够指定不同的提供者,因为这些记录需要插入到具有不同连接字符串的数据库。
基本上,是这样的:
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
功能的合适集合,而且我也不知道如何更改提供程序。
I have an IEnumerable and I would like to do a batch insert (240,000+ records). I've been perusing the forums and SO and I haven't been able to come up with something that works...
The other catch is that I need to be able to specify a different provider, as these records need to be inserted into a database with a different connection string.
Basically, something like this:
IEnumerable<MyObject> records = GetRecords();
SubSonicDooHickey.BatchSave(records, "differentSubsonicProvider")
I know that isn't exact, but something along those lines...
I've tried:
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();
(and several others) but couldn't get them to work...the above code didn't work because I couldn't find an appropriate collection from subsonic that had a .BatchSave
function on it, and I also wouldn't know how to change the provider.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明我不需要这个,但我可以使用命令让它工作:
Turns out I didn't need this, but I was able to get this to work using a command: