Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

Simple: you don't. You just use SqlBulkCopy. LINQ-to-SQL is simply a tool. SqlBulkCopy is a tool. Use the right tool for each job. Sometimes that means using something that isn't LINQ-to-SQL. This might mean creating a DataTable (or a spoof IDataReader if you are feeling ambitious) to represent the data; look perhaps at Convert generic List/Enumerable to DataTable?Convert generic List/Enumerable to DataTable? to get from your typed objects to a DataTable you can feed to SqlBulkCopy.

Simple: you don't. You just use SqlBulkCopy. LINQ-to-SQL is simply a tool. SqlBulkCopy is a tool. Use the right tool for each job. Sometimes that means using something that isn't LINQ-to-SQL. This might mean creating a DataTable (or a spoof IDataReader if you are feeling ambitious) to represent the data; look perhaps at Convert generic List/Enumerable to DataTable? to get from your typed objects to a DataTable you can feed to SqlBulkCopy.

Simple: you don't. You just use SqlBulkCopy. LINQ-to-SQL is simply a tool. SqlBulkCopy is a tool. Use the right tool for each job. Sometimes that means using something that isn't LINQ-to-SQL. This might mean creating a DataTable (or a spoof IDataReader if you are feeling ambitious) to represent the data; look perhaps at Convert generic List/Enumerable to DataTable? to get from your typed objects to a DataTable you can feed to SqlBulkCopy.

Source Link
Marc Gravell
  • 1.1m
  • 273
  • 2.6k
  • 3k

Simple: you don't. You just use SqlBulkCopy. LINQ-to-SQL is simply a tool. SqlBulkCopy is a tool. Use the right tool for each job. Sometimes that means using something that isn't LINQ-to-SQL. This might mean creating a DataTable (or a spoof IDataReader if you are feeling ambitious) to represent the data; look perhaps at Convert generic List/Enumerable to DataTable? to get from your typed objects to a DataTable you can feed to SqlBulkCopy.