In the past, I always use Class SqlBulkCopy to complete bulk insert. But I don’t know how to implement it using Linq to SQL. If inserted one by one, Efficiency will be very low.
Any good ideas?
Thanks in advance and sorry for my poor English.
In the past, I always use Class SqlBulkCopy to complete bulk insert. But I
Share
Simple: you don’t. You just use
SqlBulkCopy. LINQ-to-SQL is simply a tool.SqlBulkCopyis a tool. Use the right tool for each job. Sometimes that means using something that isn’t LINQ-to-SQL. This might mean creating aDataTable(or a spoofIDataReaderif you are feeling ambitious) to represent the data; look perhaps at Convert generic List/Enumerable to DataTable? to get from your typed objects to aDataTableyou can feed toSqlBulkCopy.