Why LINQ beats SQL
I agree with the article and try to use write my queries with Linq instead of SQL almost always.<p>The article says to avoid using Linq for bulk inserts, but for years I&#x27;ve been using an extension method to translate Linq to a bulk insert and it works fine. I forget where I found it.<p><pre><code>    public static class DataContextExtension
    {
        public static void BulkInsertAll&lt;T&gt;(this DataContext dc, IEnumerable&lt;T&gt; entities)
        {
            using (var conn = new SqlConnection(dc.Connection.ConnectionString))
            {
                conn.Open();

                Type t = typeof(T);

                var tableAttribute = (TableAttribute)t.GetCustomAttributes(
                    typeof(TableAttribute), false).Single();
                var bulkCopy = new SqlBulkCopy(conn) 
                {
                    BulkCopyTimeout = 1200,
                    DestinationTableName = tableAttribute.Name
                };

                var properties = t.GetProperties().Where(EventTypeFilter).ToArray();
                var table = new DataTable();

                foreach (var property in properties)
                {
                    Type propertyType = property.PropertyType;
                    if (propertyType.IsGenericType &amp;&amp;
                        propertyType.GetGenericTypeDefinition() == typeof(Nullable&lt;&gt;))
                    {
                        propertyType = Nullable.GetUnderlyingType(propertyType);
                    }

                    table.Columns.Add(new DataColumn(property.Name, propertyType));
                }

                foreach (var entity in entities)
                {
                    table.Rows.Add(
                        properties.Select(
                        property =&gt; property.GetValue(entity, null) ?? DBNull.Value
                        ).ToArray());
                }

                bulkCopy.WriteToServer(table);
            }
        }

        private static bool EventTypeFilter(System.Reflection.PropertyInfo p)
        {
            var attribute = Attribute.GetCustomAttribute(p,
                typeof(AssociationAttribute)) as AssociationAttribute;

            if (attribute == null) return true;
            if (attribute.IsForeignKey == false) return true;

            return false;
        }
    }</code></pre>