Hi! I'm working on an application where a lot of data is inserted into an SQL database at once. I use LINQ to SQL, and have something like this as my insert operation:
foreach (var obj in objects) { context.InsertOnSubmit(obj); } context.SubmitChanges();
Here's the problem: If I get an exception (for instance, DuplicateKeyException), I've NO CLUE what object caused the problem. The only information I'm getting is that at least one of the objects contains key values that are identical to some other key in the database.
Is it possible to extract more information about what object(s) caused the conflict?
Of course, I could call SubmitChanges after each and every InsertOnSubmit, but with the amount of data I'm inserting, this is incredibly slow.
Anyone have any tips for me? Thanks!