.NET Core MySqlBulkCopy 批量新增数据
MySqlConnector有个MySqlBulkCopy批量新增数据方法,不过只能用DataTable,需要把list转成DataTable代码如下:MySqlBulkCopy mySqlBulkCopy = new MySqlBulkCopy(conn)
{
DestinationTableName = "userinfo"
};
mySqlBulkCopy.ColumnMappings.AddRange(table.Columns.Cast<DataColumn>().Select(colum => new MySqlBulkCopyColumnMapping { DestinationColumn = colum.ColumnName, SourceOrdinal = colum.Ordinal }).ToList());
mySqlBulkCopy.WriteToServer(table);
来源:https://www.cnblogs.com/runningprogrammer/archive/2023/08/28/MySqlBulkCopy.html
免责声明:由于采集信息均来自互联网,如果侵犯了您的权益,请联系我们【E-Mail:cb@itdo.tech】 我们会及时删除侵权内容,谢谢合作!
页:
[1]