private void SetupMappings(SqlBulkCopy bcp) { var properties = GetterDelegateCache <TInput> .ReadablePropertyNames.ToArray(); var conn = bcp.GetConnection(); var destination = bcp.DestinationTableName; var destinationParts = new List <string>(SqlIdentifier.Parse(destination)); while (destinationParts.Count < 3) { destinationParts.Insert(0, null); } var schemaTable = conn.GetSchema("Columns", destinationParts.ToArray()); var columns = schemaTable.Rows.Cast <DataRow>() .Select(r => (string)r[3]) .ToArray(); foreach (var map in properties.Intersect(columns, StringComparer.InvariantCultureIgnoreCase)) { bcp.ColumnMappings.Add(new SqlBulkCopyColumnMapping(map, map)); } }