views:

212

answers:

2

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?

+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
This post uses a non-existent method "GetDeleteBatchCommand" which is useless unless I find where it is implemented
Jader Dias
is this an extension? or it is part of the .net framework?
Jader Dias
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