mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-10-31 07:49:26 +08:00 
			
		
		
		
	fix: ToDataTable
This commit is contained in:
		| @@ -168,7 +168,7 @@ namespace FreeSql | ||||
|         /// IgnoreColumns、InsertColumns | ||||
|         /// </summary> | ||||
|         /// <returns></returns> | ||||
|         DataTable ToDataTable(); | ||||
|         DataTable ToDataTable(string tableName); | ||||
|  | ||||
| #if net40 | ||||
| #else | ||||
|   | ||||
| @@ -691,10 +691,10 @@ namespace FreeSql.Internal.CommonProvider | ||||
|             return sb.ToString(); | ||||
|         } | ||||
|  | ||||
|         public DataTable ToDataTable() | ||||
|         public DataTable ToDataTable(string tableName = null) | ||||
|         { | ||||
|             var dt = new DataTable(); | ||||
|             dt.TableName = TableRuleInvoke(); | ||||
|             dt.TableName = tableName ?? TableRuleInvoke(); | ||||
|             var dtCols = new List<NativeTuple<ColumnInfo, Type, bool>>(); | ||||
|             foreach (var col in _table.ColumnsByPosition) | ||||
|             { | ||||
|   | ||||
| @@ -37,7 +37,7 @@ | ||||
| 		<PackageReference Include="System.Data.SqlClient" Version="4.8.5" /> | ||||
| 	</ItemGroup> | ||||
| 	<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0'"> | ||||
| 		<PackageReference Include="Microsoft.Data.SqlClient" Version="2.1.4" /> | ||||
| 		<PackageReference Include="Microsoft.Data.SqlClient" Version="2.1.7" /> | ||||
| 	</ItemGroup> | ||||
|  | ||||
| 	<ItemGroup> | ||||
|   | ||||
| @@ -243,13 +243,13 @@ public static partial class FreeSqlSqlServerGlobalExtensions | ||||
|     /// <param name="copyOptions"></param> | ||||
|     /// <param name="batchSize"></param> | ||||
|     /// <param name="bulkCopyTimeout"></param> | ||||
|     public static void ExecuteSqlBulkCopy<T>(this IInsert<T> that, SqlBulkCopyOptions copyOptions = SqlBulkCopyOptions.Default, int? batchSize = null, int? bulkCopyTimeout = null) where T : class | ||||
|     public static void ExecuteSqlBulkCopy<T>(this IInsert<T> that, SqlBulkCopyOptions copyOptions = SqlBulkCopyOptions.Default, int? batchSize = null, int? bulkCopyTimeout = null, string tableName = null) where T : class | ||||
|     { | ||||
|         var insert = that as FreeSql.SqlServer.Curd.SqlServerInsert<T>; | ||||
|         if (insert == null) throw new Exception(CoreStrings.S_Features_Unique("ExecuteSqlBulkCopy", "SqlServer")); | ||||
|  | ||||
|         if (insert._insertIdentity) copyOptions = copyOptions | SqlBulkCopyOptions.KeepIdentity; | ||||
|         var dt = that.ToDataTable(); | ||||
|         var dt = that.ToDataTable(tableName); | ||||
|         if (dt.Rows.Count == 0) return; | ||||
|  | ||||
|         Action<SqlBulkCopy> writeToServer = bulkCopy => | ||||
| @@ -337,13 +337,13 @@ public static partial class FreeSqlSqlServerGlobalExtensions | ||||
|         var state = ExecuteSqlBulkCopyState(update); | ||||
|         return UpdateProvider.ExecuteBulkUpdateAsync(update, state, insert => insert.ExecuteSqlBulkCopyAsync(copyOptions, batchSize, bulkCopyTimeout, cancellationToken)); | ||||
|     } | ||||
|     async public static Task ExecuteSqlBulkCopyAsync<T>(this IInsert<T> that, SqlBulkCopyOptions copyOptions = SqlBulkCopyOptions.Default, int? batchSize = null, int? bulkCopyTimeout = null, CancellationToken cancellationToken = default) where T : class | ||||
|     async public static Task ExecuteSqlBulkCopyAsync<T>(this IInsert<T> that, SqlBulkCopyOptions copyOptions = SqlBulkCopyOptions.Default, int? batchSize = null, int? bulkCopyTimeout = null, CancellationToken cancellationToken = default, string tableName = null) where T : class | ||||
|     { | ||||
|         var insert = that as FreeSql.SqlServer.Curd.SqlServerInsert<T>; | ||||
|         if (insert == null) throw new Exception(CoreStrings.S_Features_Unique("ExecuteSqlBulkCopyAsync", "SqlServer")); | ||||
|  | ||||
|         if (insert._insertIdentity) copyOptions = copyOptions | SqlBulkCopyOptions.KeepIdentity; | ||||
|         var dt = that.ToDataTable(); | ||||
|         var dt = that.ToDataTable(tableName); | ||||
|         if (dt.Rows.Count == 0) return; | ||||
|  | ||||
|         Func<SqlBulkCopy, Task> writeToServerAsync = bulkCopy => | ||||
|   | ||||
		Reference in New Issue
	
	Block a user