Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

22 update to use microsoft package as driver #24

Merged
merged 3 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog

## [2.0.0] - 2024-12-12

- Drop usage of System.Data.SqlClient in favor of Microsoft.Data.SqlClient
- Bump target framework from net451 to net462
- Self signed certificates are not accepted by default anymore
jefim marked this conversation as resolved.
Show resolved Hide resolved
- BulkInsert operation returns now long instead of int
jefim marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion Frends.Sql.Tests/Frends.Sql.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.6.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Frends.Sql.Tests/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using Microsoft.Data.SqlClient;
using System.Data.SqlTypes;
using System.IO;
using System.Linq;
Expand Down
4 changes: 2 additions & 2 deletions Frends.Sql.Tests/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"ConnectionStrings": {
"TestDbConnectionString": "Server=(local);Trusted_Connection=True;"
"TestDbConnectionString": "Persist Security Info=True; TrustServerCertificate=True; Server=localhost,5000; User Id=sa; Password=yourStrongPassword123;"
jefim marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
11 changes: 11 additions & 0 deletions Frends.Sql.Tests/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "3.9"

services:
mssql:
image: mcr.microsoft.com/mssql/server:2022-latest
container_name: mssql-server
environment:
ACCEPT_EULA: Y
MSSQL_SA_PASSWORD: yourStrongPassword123
ports:
- "5000:1433"
9 changes: 4 additions & 5 deletions Frends.Sql/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.Data.SqlClient;
using System.Linq;
using System.Reflection;
#pragma warning disable 1591
Expand All @@ -26,13 +26,12 @@ private static T GetEnum<T>(Enum enumValue)

//Get inserted row count with reflection
//http://stackoverflow.com/a/12271001
internal static int RowsCopiedCount(this SqlBulkCopy bulkCopy)
internal static long RowsCopiedCount(this SqlBulkCopy bulkCopy)
{
const string rowsCopiedFieldName = "_rowsCopied";
FieldInfo rowsCopiedField = null;
rowsCopiedField = typeof(SqlBulkCopy).GetField(rowsCopiedFieldName,
FieldInfo rowsCopiedField = typeof(SqlBulkCopy).GetField(rowsCopiedFieldName,
BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance);
return rowsCopiedField != null ? (int)rowsCopiedField.GetValue(bulkCopy) : 0;
return rowsCopiedField != null ? (long)rowsCopiedField.GetValue(bulkCopy) : 0;
jefim marked this conversation as resolved.
Show resolved Hide resolved
}

public static void SetEmptyDataRowsToNull(this DataSet dataSet)
Expand Down
8 changes: 4 additions & 4 deletions Frends.Sql/Frends.Sql.csproj
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net451</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Company>HiQ Finland</Company>
<Authors>HiQ Finland</Authors>
<Description>FRENDS Sql tasks</Description>
<Version>1.0.1</Version>
<Version>2.0.0</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dapper" Version="1.60.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="System.Data.SqlClient" Version="4.6.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
<PackageReference Include="System.ComponentModel.Annotations" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
<None Include="FrendsTaskMetadata.json" Pack="true" PackagePath="/">
<None Include="FrendsTaskMetadata.json" Pack="true" PackagePath="/">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions Frends.Sql/Sql.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Data.SqlClient;
using Microsoft.Data.SqlClient;
using System.Dynamic;
using System.IO;
using System.Threading;
Expand Down Expand Up @@ -223,7 +223,7 @@ public static async Task<int> BatchOperation([PropertyTab]InputBatchOperation in
/// <param name="input">Input parameters</param>
/// <param name="options">Optional parameters with default values</param>
/// <returns>Copied row count</returns>
public static async Task<int> BulkInsert([PropertyTab]BulkInsertInput input, [PropertyTab]BulkInsertOptions options, CancellationToken cancellationToken)
public static async Task<long> BulkInsert([PropertyTab]BulkInsertInput input, [PropertyTab]BulkInsertOptions options, CancellationToken cancellationToken)
{
var inputJson = "{\"Table\" : " + input.InputData + " }";
var dataset = JsonConvert.DeserializeObject<DataSet>(inputJson);
Expand Down Expand Up @@ -262,7 +262,7 @@ public static async Task<int> BulkInsert([PropertyTab]BulkInsertInput input, [Pr
{


int rowsCopyCount;
long rowsCopyCount;
using (var sqlBulkCopy = new SqlBulkCopy(connection, flagEnum, transaction))
{
sqlBulkCopy.BulkCopyTimeout = options.CommandTimeoutSeconds;
Expand Down
Loading
Loading