diff --git a/Frends.MicrosoftSQL.BatchOperation/CHANGELOG.md b/Frends.MicrosoftSQL.BatchOperation/CHANGELOG.md index dc4cfd4..b958838 100644 --- a/Frends.MicrosoftSQL.BatchOperation/CHANGELOG.md +++ b/Frends.MicrosoftSQL.BatchOperation/CHANGELOG.md @@ -1,13 +1,25 @@ # Changelog +## [2.2.0] - 2026-01-22 + +### Changed + +- Improve execution of async methods. + ## [2.1.0] - 2024-08-26 + ### Changed + - Updated Newtonsoft.Json to the latest version 13.0.3. ## [2.0.0] - 2024-08-05 + ### Changed + - [Breaking] The task now uses Microsoft.Data.SqlClient instead of System.Data.SqlClient. ## [1.0.0] - 2023-02-03 + ### Added + - Initial implementation diff --git a/Frends.MicrosoftSQL.BatchOperation/Frends.MicrosoftSQL.BatchOperation/BatchOperation.cs b/Frends.MicrosoftSQL.BatchOperation/Frends.MicrosoftSQL.BatchOperation/BatchOperation.cs index 996d955..56d392e 100644 --- a/Frends.MicrosoftSQL.BatchOperation/Frends.MicrosoftSQL.BatchOperation/BatchOperation.cs +++ b/Frends.MicrosoftSQL.BatchOperation/Frends.MicrosoftSQL.BatchOperation/BatchOperation.cs @@ -42,14 +42,14 @@ public static async Task BatchOperation([PropertyTab] Input input, [Prop try { using var connection = new SqlConnection(input.ConnectionString); - await connection.OpenAsync(cancellationToken); + await connection.OpenAsync(cancellationToken).ConfigureAwait(false); if (options.SqlTransactionIsolationLevel is not SqlTransactionIsolationLevel.None) { using var transaction = connection.BeginTransaction(GetIsolationLevel(options)); - return await ExecuteHandler(input, options, connection, transaction, cancellationToken); + return await ExecuteHandler(input, options, connection, transaction, cancellationToken).ConfigureAwait(false); } else - return await ExecuteHandler(input, options, connection, null, cancellationToken); + return await ExecuteHandler(input, options, connection, null, cancellationToken).ConfigureAwait(false); } catch (Exception ex) { @@ -80,7 +80,7 @@ private static async Task ExecuteHandler(Input input, Options options, S .ConfigureAwait(false); if (transaction != null) - await transaction.CommitAsync(cancellationToken); + await transaction.CommitAsync(cancellationToken).ConfigureAwait(false); return new Result(true, affectedRows, null); } @@ -97,7 +97,7 @@ private static async Task ExecuteHandler(Input input, Options options, S { try { - await transaction.RollbackAsync(cancellationToken); + await transaction.RollbackAsync(cancellationToken).ConfigureAwait(false); } catch (Exception rollbackEx) { diff --git a/Frends.MicrosoftSQL.BatchOperation/Frends.MicrosoftSQL.BatchOperation/Frends.MicrosoftSQL.BatchOperation.csproj b/Frends.MicrosoftSQL.BatchOperation/Frends.MicrosoftSQL.BatchOperation/Frends.MicrosoftSQL.BatchOperation.csproj index 4823862..b27e1a8 100644 --- a/Frends.MicrosoftSQL.BatchOperation/Frends.MicrosoftSQL.BatchOperation/Frends.MicrosoftSQL.BatchOperation.csproj +++ b/Frends.MicrosoftSQL.BatchOperation/Frends.MicrosoftSQL.BatchOperation/Frends.MicrosoftSQL.BatchOperation.csproj @@ -1,8 +1,8 @@  - net6.0 - 2.1.0 + net6.0 + 2.2.0 Frends Frends Frends diff --git a/Frends.MicrosoftSQL.BulkInsert/CHANGELOG.md b/Frends.MicrosoftSQL.BulkInsert/CHANGELOG.md index 10e98aa..0f05708 100644 --- a/Frends.MicrosoftSQL.BulkInsert/CHANGELOG.md +++ b/Frends.MicrosoftSQL.BulkInsert/CHANGELOG.md @@ -1,26 +1,47 @@ # Changelog +## [3.1.0] - 2026-01-22 + +### Changed + +- Improve execution of async methods. + ## [3.0.0] - 2025-01-15 + ### Added + - [Breaking] Added parameters ColumnMapping and ManualColumnMapping. -- Added column mapping feature which allows user to select from JsonPropertyNames, JsonPropertyOrder and ManualColumnMapping options how the column mapping is handled in bulk insert. Default behavior will remain the same JsonPropertyOrder. +- Added column mapping feature which allows user to select from JsonPropertyNames, JsonPropertyOrder and + ManualColumnMapping options how the column mapping is handled in bulk insert. Default behavior will remain the same + JsonPropertyOrder. ## [2.2.0] - 2024-09-10 + ### Changed -- Updated Options.NotifyAfter property to be set dynamically based on the total row count, with a minimum value of 1, ensuring rowsCopied is updated correctly. + +- Updated Options.NotifyAfter property to be set dynamically based on the total row count, with a minimum value of 1, + ensuring rowsCopied is updated correctly. ## [2.1.0] - 2024-08-26 + ### Changed + - Updated Newtonsoft.Json to the latest version 13.0.3. ## [2.0.0] - 2024-08-05 + ### Changed + - [Breaking] The task now uses Microsoft.Data.SqlClient instead of System.Data.SqlClient. ## [1.1.0] - 2023-01-26 + ### Added + - Options.ThrowErrorOnFailure and Result.ErrorMessage was added to let the user choose how to handle errors. ## [1.0.0] - 2023-01-10 + ### Added + - Initial implementation \ No newline at end of file diff --git a/Frends.MicrosoftSQL.BulkInsert/Frends.MicrosoftSQL.BulkInsert/BulkInsert.cs b/Frends.MicrosoftSQL.BulkInsert/Frends.MicrosoftSQL.BulkInsert/BulkInsert.cs index ef1f6b4..5429bfa 100644 --- a/Frends.MicrosoftSQL.BulkInsert/Frends.MicrosoftSQL.BulkInsert/BulkInsert.cs +++ b/Frends.MicrosoftSQL.BulkInsert/Frends.MicrosoftSQL.BulkInsert/BulkInsert.cs @@ -47,7 +47,7 @@ public static async Task BulkInsert([PropertyTab] Input input, [Property { try { - var result = await ExecuteHandler(options, input, dataSet, new SqlBulkCopy(connection, GetSqlBulkCopyOptions(options), null), cancellationToken); + var result = await ExecuteHandler(options, input, dataSet, new SqlBulkCopy(connection, GetSqlBulkCopyOptions(options), null), cancellationToken).ConfigureAwait(false); return new Result(true, result, null); } catch (Exception ex) @@ -64,15 +64,15 @@ public static async Task BulkInsert([PropertyTab] Input input, [Property try { - var result = await ExecuteHandler(options, input, dataSet, new SqlBulkCopy(connection, GetSqlBulkCopyOptions(options), transaction), cancellationToken); - await transaction.CommitAsync(cancellationToken); + var result = await ExecuteHandler(options, input, dataSet, new SqlBulkCopy(connection, GetSqlBulkCopyOptions(options), transaction), cancellationToken).ConfigureAwait(false); + await transaction.CommitAsync(cancellationToken).ConfigureAwait(false); return new Result(true, result, null); } catch (Exception ex) { try { - await transaction.RollbackAsync(cancellationToken); + await transaction.RollbackAsync(cancellationToken).ConfigureAwait(false); } catch (Exception rollbackEx) { diff --git a/Frends.MicrosoftSQL.BulkInsert/Frends.MicrosoftSQL.BulkInsert/Frends.MicrosoftSQL.BulkInsert.csproj b/Frends.MicrosoftSQL.BulkInsert/Frends.MicrosoftSQL.BulkInsert/Frends.MicrosoftSQL.BulkInsert.csproj index 92113a9..0205f71 100644 --- a/Frends.MicrosoftSQL.BulkInsert/Frends.MicrosoftSQL.BulkInsert/Frends.MicrosoftSQL.BulkInsert.csproj +++ b/Frends.MicrosoftSQL.BulkInsert/Frends.MicrosoftSQL.BulkInsert/Frends.MicrosoftSQL.BulkInsert.csproj @@ -1,28 +1,28 @@  - - net6.0 - 3.0.0 - Frends - Frends - Frends - Frends - Frends - MIT - true - Frends Task to execute bulk insert JSON data to Microsoft SQL Server. - https://frends.com/ - https://github.com/FrendsPlatform/Frends.MicrosoftSQL - - - - - PreserveNewest - - - - - - - + + net6.0 + 3.1.0 + Frends + Frends + Frends + Frends + Frends + MIT + true + Frends Task to execute bulk insert JSON data to Microsoft SQL Server. + https://frends.com/ + https://github.com/FrendsPlatform/Frends.MicrosoftSQL + + + + + PreserveNewest + + + + + + + \ No newline at end of file diff --git a/Frends.MicrosoftSQL.ExecuteProcedure/CHANGELOG.md b/Frends.MicrosoftSQL.ExecuteProcedure/CHANGELOG.md index d1fa1f6..9c12451 100644 --- a/Frends.MicrosoftSQL.ExecuteProcedure/CHANGELOG.md +++ b/Frends.MicrosoftSQL.ExecuteProcedure/CHANGELOG.md @@ -1,33 +1,54 @@ # Changelog +## [2.3.0] - 2026-01-22 + +### Changed + +- Improve execution of async methods. + ## [2.2.0] - 2024-12-16 + - Added method to form JToken from the SqlDataReader so that SqlGeography and SqlGeometry typed objects can be handled. - Fixed how Scalar handles the data so that SqlGeography and SqlGeometry typed objects can be handled. - Added Microsoft.SqlServer.Types version 160.1000.6 as dependency. ## [2.1.0] - 2024-08-26 + ### Changed + - Updated Newtonsoft.Json to the latest version 13.0.3. ## [2.0.0] - 2024-08-05 + ### Changed + - [Breaking] The task now uses Microsoft.Data.SqlClient instead of System.Data.SqlClient. ## [1.2.1] - 2024-02-12 + ### Fixed + - Fixed issue with null parameters by changing them into DBNull.Value. + ### Updated + - System.Data.SqlClient to version 4.8.6. ## [1.2.0] - 2024-01-03 + ### Changed + - [Breaking] ProcedureParameter.Value type to object so that binary data can be used. ## [1.0.1] - 2023-08-03 + ### Changed + - Documentation update to Input.Execute parameter. - Removed unnecessary runtime unloader. ## [1.0.0] - 2023-01-23 + ### Added + - Initial implementation \ No newline at end of file diff --git a/Frends.MicrosoftSQL.ExecuteProcedure/Frends.MicrosoftSQL.ExecuteProcedure/ExecuteProcedure.cs b/Frends.MicrosoftSQL.ExecuteProcedure/Frends.MicrosoftSQL.ExecuteProcedure/ExecuteProcedure.cs index 30f2bda..3891be4 100644 --- a/Frends.MicrosoftSQL.ExecuteProcedure/Frends.MicrosoftSQL.ExecuteProcedure/ExecuteProcedure.cs +++ b/Frends.MicrosoftSQL.ExecuteProcedure/Frends.MicrosoftSQL.ExecuteProcedure/ExecuteProcedure.cs @@ -32,7 +32,7 @@ public static async Task ExecuteProcedure([PropertyTab] Input input, [Pr using var connection = new SqlConnection(input.ConnectionString); try { - await connection.OpenAsync(cancellationToken); + await connection.OpenAsync(cancellationToken).ConfigureAwait(false); using var command = connection.CreateCommand(); command.CommandTimeout = options.CommandTimeoutSeconds; @@ -58,12 +58,12 @@ public static async Task ExecuteProcedure([PropertyTab] Input input, [Pr } if (options.SqlTransactionIsolationLevel is SqlTransactionIsolationLevel.None) - result = await ExecuteHandler(input, options, command, cancellationToken); + result = await ExecuteHandler(input, options, command, cancellationToken).ConfigureAwait(false); else { using var transaction = connection.BeginTransaction(GetIsolationLevel(options.SqlTransactionIsolationLevel)); command.Transaction = transaction; - result = await ExecuteHandler(input, options, command, cancellationToken); + result = await ExecuteHandler(input, options, command, cancellationToken).ConfigureAwait(false); } return result; @@ -104,22 +104,22 @@ private static async Task ExecuteHandler(Input input, Options options, S break; case ExecuteTypes.ExecuteReader: dataReader = await command.ExecuteReaderAsync(cancellationToken).ConfigureAwait(false); - result = new Result(true, dataReader.RecordsAffected, null, await LoadData(dataReader, cancellationToken)); - await dataReader.CloseAsync(); + result = new Result(true, dataReader.RecordsAffected, null, await LoadData(dataReader, cancellationToken).ConfigureAwait(false)); + await dataReader.CloseAsync().ConfigureAwait(false); break; default: throw new NotSupportedException(); } if (command.Transaction != null) - await command.Transaction.CommitAsync(cancellationToken); + await command.Transaction.CommitAsync(cancellationToken).ConfigureAwait(false); return result; } catch (Exception ex) { if (dataReader != null && !dataReader.IsClosed) - await dataReader.CloseAsync(); + await dataReader.CloseAsync().ConfigureAwait(false); return HandleExecutionException(ex, options, command); } @@ -130,7 +130,7 @@ private static async Task LoadData(SqlDataReader reader, CancellationTok var table = new JArray(); while (reader.HasRows) { - while (await reader.ReadAsync(cancellationToken)) + while (await reader.ReadAsync(cancellationToken).ConfigureAwait(false)) { var row = new JObject(); for (var i = 0; i < reader.FieldCount; i++) diff --git a/Frends.MicrosoftSQL.ExecuteProcedure/Frends.MicrosoftSQL.ExecuteProcedure/Frends.MicrosoftSQL.ExecuteProcedure.csproj b/Frends.MicrosoftSQL.ExecuteProcedure/Frends.MicrosoftSQL.ExecuteProcedure/Frends.MicrosoftSQL.ExecuteProcedure.csproj index 75349d8..95b6ce4 100644 --- a/Frends.MicrosoftSQL.ExecuteProcedure/Frends.MicrosoftSQL.ExecuteProcedure/Frends.MicrosoftSQL.ExecuteProcedure.csproj +++ b/Frends.MicrosoftSQL.ExecuteProcedure/Frends.MicrosoftSQL.ExecuteProcedure/Frends.MicrosoftSQL.ExecuteProcedure.csproj @@ -1,29 +1,29 @@  - - net6.0 - 2.2.0 - Frends - Frends - Frends - Frends - Frends - MIT - true - Frends Task to execute Microsoft SQL Server procedure. - https://frends.com/ - https://github.com/FrendsPlatform/Frends.MicrosoftSQL - - - - - PreserveNewest - - - - - - - - + + net6.0 + 2.3.0 + Frends + Frends + Frends + Frends + Frends + MIT + true + Frends Task to execute Microsoft SQL Server procedure. + https://frends.com/ + https://github.com/FrendsPlatform/Frends.MicrosoftSQL + + + + + PreserveNewest + + + + + + + + \ No newline at end of file diff --git a/Frends.MicrosoftSQL.ExecuteQuery/CHANGELOG.md b/Frends.MicrosoftSQL.ExecuteQuery/CHANGELOG.md index 609650c..ba49146 100644 --- a/Frends.MicrosoftSQL.ExecuteQuery/CHANGELOG.md +++ b/Frends.MicrosoftSQL.ExecuteQuery/CHANGELOG.md @@ -1,35 +1,59 @@ # Changelog +## [2.3.0] - 2026-01-22 + +### Changed + +- Improve execution of async methods. + ## [2.2.0] - 2024-11-26 + ### Added + - Added method to form JToken from the SqlDataReader so that SqlGeography and SqlGeometry typed objects can be handled. - Fixed how Scalar handles the data so that SqlGeography and SqlGeometry typed objects can be handled. - Added Microsoft.SqlServer.Types version 160.1000.6 as dependency. ## [2.1.0] - 2024-09-10 + ### Fixed + - Fixed how null values are handled by setting them as DBNull.Value. -- Fixed how JValue parameters are handled by adding a check for those values and assigning ToString() method on the values. +- Fixed how JValue parameters are handled by adding a check for those values and assigning ToString() method on the + values. ## [2.0.0] - 2024-08-01 + ### Changed + - [Breaking] The task now uses Microsoft.Data.SqlClient instead of System.Data.SqlClient. ## [1.2.1] - 2024-03-01 + ### Changed -- Removed finally block from the Task so that the SQLConnection pool is not touched after every call to the ExecuteQuery method. + +- Removed finally block from the Task so that the SQLConnection pool is not touched after every call to the ExecuteQuery + method. + ### Updated + - Newtonsoft.Json to version 13.0.3 - System.Data.SqlClient to version 4.8.6 ## [1.2.0] - 2023-11-30 + ### Changed + - [Breaking] QueryParameter.Value type to object so that binary data can be used. ## [1.1.0] - 2023-01-27 + ### Changed + - Naming: Result.QueryResult to Result.Data. ## [1.0.0] - 2023-01-18 + ### Added + - Initial implementation \ No newline at end of file diff --git a/Frends.MicrosoftSQL.ExecuteQuery/Frends.MicrosoftSQL.ExecuteQuery/ExecuteQuery.cs b/Frends.MicrosoftSQL.ExecuteQuery/Frends.MicrosoftSQL.ExecuteQuery/ExecuteQuery.cs index b3dc7be..d8648a6 100644 --- a/Frends.MicrosoftSQL.ExecuteQuery/Frends.MicrosoftSQL.ExecuteQuery/ExecuteQuery.cs +++ b/Frends.MicrosoftSQL.ExecuteQuery/Frends.MicrosoftSQL.ExecuteQuery/ExecuteQuery.cs @@ -31,7 +31,7 @@ public static async Task ExecuteQuery([PropertyTab] Input input, [Proper using var connection = new SqlConnection(input.ConnectionString); try { - await connection.OpenAsync(cancellationToken); + await connection.OpenAsync(cancellationToken).ConfigureAwait(false); using var command = connection.CreateCommand(); command.CommandTimeout = options.CommandTimeoutSeconds; @@ -67,12 +67,12 @@ public static async Task ExecuteQuery([PropertyTab] Input input, [Proper } if (options.SqlTransactionIsolationLevel is SqlTransactionIsolationLevel.None) - result = await ExecuteHandler(input, options, command, cancellationToken); + result = await ExecuteHandler(input, options, command, cancellationToken).ConfigureAwait(false); else { using var transaction = connection.BeginTransaction(GetIsolationLevel(options)); command.Transaction = transaction; - result = await ExecuteHandler(input, options, command, cancellationToken); + result = await ExecuteHandler(input, options, command, cancellationToken).ConfigureAwait(false); } return result; @@ -102,8 +102,8 @@ private static async Task ExecuteHandler(Input input, Options options, S if (input.Query.ToLower().StartsWith("select")) { dataReader = await command.ExecuteReaderAsync(cancellationToken).ConfigureAwait(false); - result = new Result(true, dataReader.RecordsAffected, null, await LoadData(dataReader, cancellationToken)); - await dataReader.CloseAsync(); + result = new Result(true, dataReader.RecordsAffected, null, await LoadData(dataReader, cancellationToken).ConfigureAwait(false)); + await dataReader.CloseAsync().ConfigureAwait(false); break; } dataObject = await command.ExecuteNonQueryAsync(cancellationToken).ConfigureAwait(false); @@ -124,22 +124,22 @@ private static async Task ExecuteHandler(Input input, Options options, S break; case ExecuteTypes.ExecuteReader: dataReader = await command.ExecuteReaderAsync(cancellationToken).ConfigureAwait(false); - result = new Result(true, dataReader.RecordsAffected, null, await LoadData(dataReader, cancellationToken)); - await dataReader.CloseAsync(); + result = new Result(true, dataReader.RecordsAffected, null, await LoadData(dataReader, cancellationToken).ConfigureAwait(false)); + await dataReader.CloseAsync().ConfigureAwait(false); break; default: throw new NotSupportedException(); } if (command.Transaction != null) - await command.Transaction.CommitAsync(cancellationToken); + await command.Transaction.CommitAsync(cancellationToken).ConfigureAwait(false); return result; } catch (Exception ex) { if (dataReader != null && !dataReader.IsClosed) - await dataReader.CloseAsync(); + await dataReader.CloseAsync().ConfigureAwait(false); if (command.Transaction is null) { @@ -152,7 +152,7 @@ private static async Task ExecuteHandler(Input input, Options options, S { try { - await command.Transaction.RollbackAsync(cancellationToken); + await command.Transaction.RollbackAsync(cancellationToken).ConfigureAwait(false); } catch (Exception rollbackEx) { @@ -171,7 +171,7 @@ private static async Task ExecuteHandler(Input input, Options options, S finally { if (dataReader != null && !dataReader.IsClosed) - await dataReader.CloseAsync(); + await dataReader.CloseAsync().ConfigureAwait(false); } } @@ -180,7 +180,7 @@ private static async Task LoadData(SqlDataReader reader, CancellationTok var table = new JArray(); while (reader.HasRows) { - while (await reader.ReadAsync(cancellationToken)) + while (await reader.ReadAsync(cancellationToken).ConfigureAwait(false)) { var row = new JObject(); for (var i = 0; i < reader.FieldCount; i++) diff --git a/Frends.MicrosoftSQL.ExecuteQuery/Frends.MicrosoftSQL.ExecuteQuery/Frends.MicrosoftSQL.ExecuteQuery.csproj b/Frends.MicrosoftSQL.ExecuteQuery/Frends.MicrosoftSQL.ExecuteQuery/Frends.MicrosoftSQL.ExecuteQuery.csproj index 38389f9..4e4c7eb 100644 --- a/Frends.MicrosoftSQL.ExecuteQuery/Frends.MicrosoftSQL.ExecuteQuery/Frends.MicrosoftSQL.ExecuteQuery.csproj +++ b/Frends.MicrosoftSQL.ExecuteQuery/Frends.MicrosoftSQL.ExecuteQuery/Frends.MicrosoftSQL.ExecuteQuery.csproj @@ -1,29 +1,29 @@  - - net6.0 - 2.2.0 - Frends - Frends - Frends - Frends - Frends - MIT - true - Execute MSSQL query. - https://frends.com/ - https://github.com/FrendsPlatform/Frends.MicrosoftSQL - - - - - PreserveNewest - - - - - - - - + + net6.0 + 2.3.0 + Frends + Frends + Frends + Frends + Frends + MIT + true + Execute MSSQL query. + https://frends.com/ + https://github.com/FrendsPlatform/Frends.MicrosoftSQL + + + + + PreserveNewest + + + + + + + + \ No newline at end of file diff --git a/Frends.MicrosoftSQL.ExecuteQueryToFile/CHANGELOG.md b/Frends.MicrosoftSQL.ExecuteQueryToFile/CHANGELOG.md index 528ac6f..4a398c7 100644 --- a/Frends.MicrosoftSQL.ExecuteQueryToFile/CHANGELOG.md +++ b/Frends.MicrosoftSQL.ExecuteQueryToFile/CHANGELOG.md @@ -1,17 +1,31 @@ # Changelog +## [2.2.0] - 2026-01-22 + +### Changed + +- Improve execution of async methods. + ## [2.1.0] - 2024-12-16 + ### Added + - Added Microsoft.SqlServer.Types dependency so that SqlGeography and SqlGeometry typed objects can be handled. ## [2.0.0] - 2024-08-05 + ### Changed + - [Breaking] The task now uses Microsoft.Data.SqlClient instead of System.Data.SqlClient. ## [1.0.1] - 2024-02-12 + ### Fixed + - Fixed handling of null query parameters by changing the parameter value to DBNull.Value. ## [1.0.0] - 2024-02-07 + ### Changed + - Initial implementation diff --git a/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile/Definitions/CsvFileWriter.cs b/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile/Definitions/CsvFileWriter.cs index 7015525..3ec19e4 100644 --- a/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile/Definitions/CsvFileWriter.cs +++ b/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile/Definitions/CsvFileWriter.cs @@ -40,7 +40,7 @@ public async Task SaveQueryToCSV(CancellationToken cancellationToken) { writer.NewLine = Options.GetLineBreakAsString(); - var reader = await SqlCommand.ExecuteReaderAsync(cancellationToken); + var reader = await SqlCommand.ExecuteReaderAsync(cancellationToken).ConfigureAwait(false); output = DataReaderToCsv(reader, csvFile, Options, cancellationToken); csvFile.Flush(); @@ -67,6 +67,7 @@ private static string FormatDbHeader(string header, bool forceSpecialFormatting) // Second part removed any leading numbers or underscoress. var rgx = new Regex("[^a-zA-Z0-9_-]|^[0-9_]+"); header = rgx.Replace(header, string.Empty); + return header.ToLower(); } @@ -76,6 +77,7 @@ private static string FormatDbValue(object value, string dbTypeName, Type dotnet { if (dotnetType == typeof(string)) return "\"\""; if (dotnetType == typeof(DateTime) && options.AddQuotesToDates) return "\"\""; + return string.Empty; } @@ -87,8 +89,10 @@ private static string FormatDbValue(object value, string dbTypeName, Type dotnet str = str.Replace("\r\n", " "); str = str.Replace("\r", " "); str = str.Replace("\n", " "); + if (options.AddQuotesToStrings) return $"\"{str}\""; + return str; } @@ -101,7 +105,9 @@ private static string FormatDbValue(object value, string dbTypeName, Type dotnet "date" => dateTime.ToString(options.DateFormat, CultureInfo.InvariantCulture), _ => dateTime.ToString(options.DateTimeFormat, CultureInfo.InvariantCulture), }; + if (options.AddQuotesToDates) return $"\"{output}\""; + return output; } @@ -128,6 +134,7 @@ private static int DataReaderToCsv( { // Write header and remember column indexes to include. var columnIndexesToInclude = new List(); + for (var i = 0; i < reader.FieldCount; i++) { var columnName = reader.GetName(i); @@ -153,6 +160,7 @@ private static int DataReaderToCsv( if (options.IncludeHeadersInOutput) csvWriter.NextRecord(); int count = 0; + while (reader.Read()) { foreach (var columnIndex in columnIndexesToInclude) @@ -184,4 +192,4 @@ private static Encoding GetEncoding(FileEncoding optionsFileEncoding, bool optio _ => Encoding.ASCII, }; } -} +} \ No newline at end of file diff --git a/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile/Enums/FileEncoding.cs b/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile/Enums/FileEncoding.cs index cdc2840..7a5d692 100644 --- a/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile/Enums/FileEncoding.cs +++ b/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile/Enums/FileEncoding.cs @@ -1,7 +1,6 @@ namespace Frends.MicrosoftSQL.ExecuteQueryToFile.Enums; #pragma warning disable CS1591 // Self-explanatory - /// /// File encoding used to encode the file. /// @@ -14,4 +13,4 @@ public enum FileEncoding Other, } -#pragma warning restore CS1591 // Self-explanatory \ No newline at end of file +#pragma warning restore CS1591 // Self-explanatory diff --git a/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile/Enums/ReturnFormat.cs b/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile/Enums/ReturnFormat.cs index f37af8c..1f2749e 100644 --- a/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile/Enums/ReturnFormat.cs +++ b/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile/Enums/ReturnFormat.cs @@ -1,7 +1,6 @@ namespace Frends.MicrosoftSQL.ExecuteQueryToFile.Enums; #pragma warning disable CS1591 // Self-explanatory - /// /// Enumeration for output format. /// @@ -10,4 +9,4 @@ public enum ReturnFormat CSV, } -#pragma warning restore CS1591 // Self-explanatory \ No newline at end of file +#pragma warning restore CS1591 // Self-explanatory diff --git a/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile.csproj b/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile.csproj index ec6c0bf..74f7074 100644 --- a/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile.csproj +++ b/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile/Frends.MicrosoftSQL.ExecuteQueryToFile.csproj @@ -1,49 +1,49 @@  - - net6.0 - Latest - 2.1.0 - Frends - Frends - Frends - Frends - Frends - MIT - true - Frends Task for executing Microsoft SQL queries into a file. - https://frends.com/ - https://github.com/FrendsPlatform/Frends.MicrosoftSQL/tree/main/Frends.MicrosoftSQL.ExecuteQueryToFile - + + net6.0 + Latest + 2.2.0 + Frends + Frends + Frends + Frends + Frends + MIT + true + Frends Task for executing Microsoft SQL queries into a file. + https://frends.com/ + https://github.com/FrendsPlatform/Frends.MicrosoftSQL/tree/main/Frends.MicrosoftSQL.ExecuteQueryToFile + - - - - PreserveNewest - - + + + + PreserveNewest + + - - - <_Parameter1>$(MSBuildProjectName).Tests - - + + + <_Parameter1>$(MSBuildProjectName).Tests + + - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers - - + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers + +