Skip to content

Commit 912148c

Browse files
authored
Merge pull request #24 from FrendsPlatform/22-update-to-use-microsoft-package-as-driver
22 update to use microsoft package as driver
2 parents e154581 + 70037b6 commit 912148c

File tree

9 files changed

+109
-70
lines changed

9 files changed

+109
-70
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changelog
2+
3+
## [2.0.0] - 2024-12-12
4+
5+
- Drop usage of System.Data.SqlClient in favor of Microsoft.Data.SqlClient
6+
- Bump target framework from net451 to net462
7+
- Self signed certificates are not accepted by default anymore
8+
- BulkInsert operation returns now long instead of int

Frends.Sql.Tests/Frends.Sql.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.2.0" />
1212
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
1313
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
14-
<PackageReference Include="System.Data.SqlClient" Version="4.6.0" />
14+
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
1515
<PackageReference Include="xunit" Version="2.3.1" />
1616
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
1717
</ItemGroup>

Frends.Sql.Tests/UnitTest1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Collections.Generic;
33
using System.Configuration;
44
using System.Data;
5-
using System.Data.SqlClient;
5+
using Microsoft.Data.SqlClient;
66
using System.Data.SqlTypes;
77
using System.IO;
88
using System.Linq;

Frends.Sql.Tests/appsettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"ConnectionStrings": {
3-
"TestDbConnectionString": "Server=(local);Trusted_Connection=True;"
3+
"TestDbConnectionString": "Persist Security Info=True; TrustServerCertificate=True; Server=localhost,5000; User Id=sa; Password=yourStrongPassword123;"
44
}
5-
}
5+
}

Frends.Sql.Tests/docker-compose.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: "3.9"
2+
3+
services:
4+
mssql:
5+
image: mcr.microsoft.com/mssql/server:2022-latest
6+
container_name: mssql-server
7+
environment:
8+
ACCEPT_EULA: Y
9+
MSSQL_SA_PASSWORD: yourStrongPassword123
10+
ports:
11+
- "5000:1433"

Frends.Sql/Extensions.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22
using System.Data;
3-
using System.Data.SqlClient;
3+
using Microsoft.Data.SqlClient;
44
using System.Linq;
55
using System.Reflection;
66
#pragma warning disable 1591
@@ -26,13 +26,12 @@ private static T GetEnum<T>(Enum enumValue)
2626

2727
//Get inserted row count with reflection
2828
//http://stackoverflow.com/a/12271001
29-
internal static int RowsCopiedCount(this SqlBulkCopy bulkCopy)
29+
internal static long RowsCopiedCount(this SqlBulkCopy bulkCopy)
3030
{
3131
const string rowsCopiedFieldName = "_rowsCopied";
32-
FieldInfo rowsCopiedField = null;
33-
rowsCopiedField = typeof(SqlBulkCopy).GetField(rowsCopiedFieldName,
32+
FieldInfo rowsCopiedField = typeof(SqlBulkCopy).GetField(rowsCopiedFieldName,
3433
BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance);
35-
return rowsCopiedField != null ? (int)rowsCopiedField.GetValue(bulkCopy) : 0;
34+
return rowsCopiedField != null ? (long)rowsCopiedField.GetValue(bulkCopy) : 0;
3635
}
3736

3837
public static void SetEmptyDataRowsToNull(this DataSet dataSet)

Frends.Sql/Frends.Sql.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;net451</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
55
<GenerateDocumentationFile>true</GenerateDocumentationFile>
66
<Company>HiQ Finland</Company>
77
<Authors>HiQ Finland</Authors>
88
<Description>FRENDS Sql tasks</Description>
9-
<Version>1.0.1</Version>
9+
<Version>2.0.0</Version>
1010
</PropertyGroup>
1111

1212
<ItemGroup>
1313
<PackageReference Include="Dapper" Version="1.60.1" />
1414
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
15-
<PackageReference Include="System.Data.SqlClient" Version="4.6.0" />
15+
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
1616
<PackageReference Include="System.ComponentModel.Annotations" Version="4.5.0" />
1717
</ItemGroup>
1818

1919
<ItemGroup>
20-
<None Include="FrendsTaskMetadata.json" Pack="true" PackagePath="/">
20+
<None Include="FrendsTaskMetadata.json" Pack="true" PackagePath="/">
2121
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2222
</None>
2323
</ItemGroup>

Frends.Sql/Sql.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.ComponentModel;
44
using System.ComponentModel.DataAnnotations;
55
using System.Data;
6-
using System.Data.SqlClient;
6+
using Microsoft.Data.SqlClient;
77
using System.Dynamic;
88
using System.IO;
99
using System.Threading;
@@ -223,7 +223,7 @@ public static async Task<int> BatchOperation([PropertyTab]InputBatchOperation in
223223
/// <param name="input">Input parameters</param>
224224
/// <param name="options">Optional parameters with default values</param>
225225
/// <returns>Copied row count</returns>
226-
public static async Task<int> BulkInsert([PropertyTab]BulkInsertInput input, [PropertyTab]BulkInsertOptions options, CancellationToken cancellationToken)
226+
public static async Task<long> BulkInsert([PropertyTab]BulkInsertInput input, [PropertyTab]BulkInsertOptions options, CancellationToken cancellationToken)
227227
{
228228
var inputJson = "{\"Table\" : " + input.InputData + " }";
229229
var dataset = JsonConvert.DeserializeObject<DataSet>(inputJson);
@@ -262,7 +262,7 @@ public static async Task<int> BulkInsert([PropertyTab]BulkInsertInput input, [Pr
262262
{
263263

264264

265-
int rowsCopyCount;
265+
long rowsCopyCount;
266266
using (var sqlBulkCopy = new SqlBulkCopy(connection, flagEnum, transaction))
267267
{
268268
sqlBulkCopy.BulkCopyTimeout = options.CommandTimeoutSeconds;

0 commit comments

Comments
 (0)