We know that Linq-To-Sql InsertAllOnSubmit sucks in terms of performance, but using SqlBulkCopy for mass insertions requires some coding. Have anyone found any code/library that uses SqlBulkCopy in a InsertAllOnSubmit alternative implementation as simple to use as the original?
views:
212answers:
2
+2
Q:
Is there a library with an alternative InsertAllOnSubmit implementation which uses SqlBulkCopy?
+2
A:
All I found that came close to produce such a library is this blog : Batch Updates and Deletes with LINQ to SQL
It's a step in the right direction imo
EDIT : In relation to that comment about the GetDeleteBatchCommand. It's in the source code. Here's a the code :
private static DbCommand GetDeleteBatchCommand<TEntity>(this Table<TEntity> table, IQueryable<TEntity> entities) where TEntity : class
{
var deleteCommand = table.Context.GetCommand(entities);
deleteCommand.CommandText = string.Format("DELETE {0}\r\n", table.GetDbName()) + GetBatchJoinQuery<TEntity>(table, entities);
return deleteCommand;
}
Mathlec
2009-10-02 15:58:07
This post uses a non-existent method "GetDeleteBatchCommand" which is useless unless I find where it is implemented
Jader Dias
2009-10-02 21:00:57
is this an extension? or it is part of the .net framework?
Jader Dias
2009-10-06 11:29:22
It's an extension using Expression and Extensions. I'm sure you could either contact the guy or build something around the UpdateBatch. It's well writen and there's even some comments! <gasp>
Mathlec
2009-10-06 11:51:58
+1
A:
I found this: http://blogs.microsoft.co.il/blogs/aviwortzel/archive/2008/05/06/implementing-sqlbulkcopy-in-linq-to-sql.aspx
Jader Dias
2009-10-08 14:23:01