Skip to content

Commit 37dea7e

Browse files
committed
Refs: #40 Replace System.Data.SqlClient with Microsoft.Data.SqlClient
This commit includes a significant change where the `System.Data.SqlClient` package has been replaced with `Microsoft.Data.SqlClient` across multiple files. This is a breaking change and is highlighted in the `Changelog.md` file. The `Microsoft.Data.SqlClient` package is the latest and recommended data provider for SQL Server. The connection string for `NEventStore.MsSql` in the `README.md` file has been updated. The `.editorconfig` file now includes new rules for code formatting and style. The `NEventStore.Persistence.Sql.nuspec` file and several project files have been updated to replace the `System.Data.SqlClient` dependency with `Microsoft.Data.SqlClient`. Several test files have been updated to use `Microsoft.Data.SqlClient` and their code formatting has been updated. The `using System.Data.SqlClient;` and `using Microsoft.Data.SqlClient;` statements have been removed from the `MsSqlDialect.cs` file, and the `using System;` statement has been added. The `#if NET462` preprocessor directive and its associated code have been removed. The `SqlException` class from the `System.Data.SqlClient` namespace has been replaced with the `SqlException` class from the `Microsoft.Data.SqlClient` namespace in the `IsDuplicate` method. Lastly, the `MsSqlDialect` and `MsSql2005Dialect` classes have been restructured but their functionality remains the same.
1 parent 4aee689 commit 37dea7e

10 files changed

+479
-485
lines changed

Changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# NEventStore.Persistence.Sql
22

3+
## vNext
4+
5+
- Using Microsoft.Data.SqlClient instead of System.Data.SqlClient [#40](https://github.com/NEventStore/NEventStore.Persistence.SQL/issues/40)
6+
7+
### Breaking Change
8+
9+
- System.Data.SqlClient is not supported anymore.
10+
- To properly update to Microsoft.Data.SqlClient follow the guirelines in [SqlClient porting cheat sheet](https://github.com/dotnet/SqlClient/blob/main/porting-cheat-sheet.md).
11+
312
## 9.1.2
413

514
- fixed .nuspec file (wrong net462 references)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ To build the project locally on a Windows Machine:
6060
- Define the following environment variables:
6161

6262
```
63-
NEventStore.MsSql="Server=localhost,50001;Database=NEventStore;User Id=sa;Password=Password1;"
63+
NEventStore.MsSql="Server=localhost,50001;Database=NEventStore;User Id=sa;Password=Password1;TrustServerCertificate=True;"
6464
NEventStore.MySql="Server=localhost;Port=50003;Database=NEventStore;Uid=sa;Pwd=Password1;AutoEnlist=false;"
6565
NEventStore.PostgreSql="Server=localhost;Port=50004;Database=NEventStore;Uid=sa;Pwd=Password1;Enlist=false;"
6666
NEventStore.Oracle="Data Source=localhost:1521/XE;User Id=system;Password=Password1;Persist Security Info=True;"

src/.editorconfig

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
1-
[*]
1+
[*]
2+
23
end_of_line = crlf
3-
indent_style = space
4-
indent_size = 4
4+
indent_style = tab
5+
trim_trailing_whitespace = true
56

67
[*.xml]
7-
indent_style = space
8+
9+
indent_style = tab
10+
11+
[*.cs]
12+
13+
csharp_new_line_before_open_brace = all
14+
15+
# RCS1229: Use async/await when necessary.
16+
dotnet_diagnostic.RCS1229.severity = error
17+
18+
# IDE0063: Use simple 'using' statement
19+
csharp_prefer_simple_using_statement = false
20+
21+
# IDE0090: Use 'new(...)'
22+
csharp_style_implicit_object_creation_when_type_is_apparent = false
23+
24+
# IDE0290: Use primary constructor
25+
csharp_style_prefer_primary_constructors = false
26+
27+
# IDE0028: Simplify collection initialization
28+
dotnet_style_collection_initializer = false

src/.nuget/NEventStore.Persistence.Sql.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
<group targetFramework=".NETFramework4.6.2">
2424
<dependency id="NEventStore" version="[9.1.1,10.0.0)" exclude="Build,Analyzers"/>
2525
<dependency id="Microsoft.Extensions.Logging.Abstractions" version="7.0.1" exclude="Build,Analyzers" />
26-
<dependency id="System.Data.SqlClient" version="4.8.5" exclude="Build,Analyzers" />
26+
<dependency id="Microsoft.Data.SqlClient" version="5.2.0" exclude="Build,Analyzers" />
2727
</group>
2828
<group targetFramework=".NETStandard2.0">
2929
<dependency id="NEventStore" version="[9.1.1,10.0.0)" exclude="Build,Analyzers"/>
3030
<dependency id="Microsoft.Extensions.Logging.Abstractions" version="7.0.1" exclude="Build,Analyzers" />
31-
<dependency id="System.Data.SqlClient" version="4.8.5" exclude="Build,Analyzers" />
31+
<dependency id="Microsoft.Data.SqlClient" version="5.2.0" exclude="Build,Analyzers" />
3232
</group>
3333
</dependencies>
3434
<frameworkAssemblies>

src/NEventStore.Persistence.MsSql.Tests/NEventStore.Persistence.MsSql.Core.Tests.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.0" />
1818
</ItemGroup>
1919
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
20-
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
2120
<Reference Include="System.Transactions" />
2221
</ItemGroup>
2322
<ItemGroup>

src/NEventStore.Persistence.MsSql.Tests/PersistenceEngineFixture.cs

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,28 @@
22

33
namespace NEventStore.Persistence.AcceptanceTests
44
{
5-
using NEventStore.Persistence.Sql;
6-
using NEventStore.Persistence.Sql.SqlDialects;
7-
using NEventStore.Serialization;
8-
#if NET462
9-
using System.Data.SqlClient;
10-
#else
11-
using Microsoft.Data.SqlClient;
12-
#endif
13-
using System.Transactions;
5+
using NEventStore.Persistence.Sql;
6+
using NEventStore.Persistence.Sql.SqlDialects;
7+
using NEventStore.Serialization;
8+
using System.Transactions;
149

15-
public partial class PersistenceEngineFixture
16-
{
17-
/// <summary>
18-
/// this mimic the current NEventStore default values which is run outside any transaction (creates a scope that
19-
/// suppresses any transaction)
20-
/// </summary>
21-
public TransactionScopeOption? ScopeOption { get; set; } = null; // the old default: TransactionScopeOption.Suppress;
10+
public partial class PersistenceEngineFixture
11+
{
12+
/// <summary>
13+
/// this mimic the current NEventStore default values which is run outside any transaction (creates a scope that
14+
/// suppresses any transaction)
15+
/// </summary>
16+
public TransactionScopeOption? ScopeOption { get; set; } = null; // the old default: TransactionScopeOption.Suppress;
2217

23-
public PersistenceEngineFixture()
24-
{
25-
#if NET462
26-
_createPersistence = pageSize =>
27-
new SqlPersistenceFactory(new EnviromentConnectionFactory("MsSql", "System.Data.SqlClient"),
28-
new BinarySerializer(),
29-
new MsSqlDialect(),
30-
pageSize: pageSize,
31-
scopeOption: ScopeOption
32-
).Build();
33-
#else
34-
_createPersistence = pageSize =>
35-
new SqlPersistenceFactory(new EnviromentConnectionFactory("MsSql", SqlClientFactory.Instance),
36-
new BinarySerializer(),
37-
new MsSqlDialect(),
38-
pageSize: pageSize,
39-
scopeOption: ScopeOption
40-
).Build();
41-
#endif
42-
}
43-
}
18+
public PersistenceEngineFixture()
19+
{
20+
_createPersistence = pageSize =>
21+
new SqlPersistenceFactory(new EnviromentConnectionFactory("MsSql", Microsoft.Data.SqlClient.SqlClientFactory.Instance),
22+
new BinarySerializer(),
23+
new MsSqlDialect(),
24+
pageSize: pageSize,
25+
scopeOption: ScopeOption
26+
).Build();
27+
}
28+
}
4429
}

0 commit comments

Comments
 (0)