Skip to content

Commit 4194e88

Browse files
committed
v0.4.1
1 parent 0df9400 commit 4194e88

13 files changed

+46
-244
lines changed

samples/MoviesAppSample/DataAccess/PersonDal.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,9 @@ public ValueTask<bool> SaveMovieWritersAsync(SQLiteDbContext context, long movie
105105

106106
private ValueTask<bool> SaveMoviePersonsAsync(SQLiteDbContext context, string tableName, long movieId, List<PersonDto> dtos, CancellationToken cancellationToken)
107107
{
108-
#if NET6_0_OR_GREATER
109108
ArgumentNullException.ThrowIfNull(dtos);
110-
#else
111-
Throw.IfNull(dtos);
112-
#endif
113109
Debug.Assert(movieId > 0);
110+
114111
cancellationToken.ThrowIfCancellationRequested();
115112
return TryExecuteInDbContextAsync(context, ctx =>
116113
{
@@ -151,11 +148,7 @@ private ValueTask<bool> SaveMoviePersonsAsync(SQLiteDbContext context, string ta
151148

152149
public ValueTask<bool> SavePersonsAsync(SQLiteDbContext context, List<PersonDto> dtos, CancellationToken cancellationToken)
153150
{
154-
#if NET6_0_OR_GREATER
155151
ArgumentNullException.ThrowIfNull(dtos);
156-
#else
157-
Throw.IfNull(dtos);
158-
#endif
159152

160153
cancellationToken.ThrowIfCancellationRequested();
161154
return TryExecuteInDbContextAsync(context, ctx =>

samples/MoviesAppSample/Models/Movie.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@ public static class MovieExtensions
1818
{
1919
public static MovieDto ToDto(this Movie movie)
2020
{
21-
#if NET6_0_OR_GREATER
2221
ArgumentNullException.ThrowIfNull(movie);
23-
#else
24-
Throw.IfNull(movie);
25-
#endif
22+
2623
return new MovieDto(movie.Id, movie.Title, movie.Description, movie.DateReleased);
2724
}
2825
}

samples/MoviesAppSample/Models/Person.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ public static class PersonExtensions
1313
{
1414
public static PersonDto ToDto(this Person person)
1515
{
16-
#if NET6_0_OR_GREATER
1716
ArgumentNullException.ThrowIfNull(person);
18-
#else
19-
Throw.IfNull(person);
20-
#endif
17+
2118
return new PersonDto(person.Id, person.Name);
2219
}
2320
}

src/NuExt.System.Data.SQLite.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
This is necessary as the assembly version in the already shipped packages is higher than what's provided inbox on .NET Framework. -->
77
<Nullable>enable</Nullable>
88
<ImplicitUsings>enable</ImplicitUsings>
9-
<TreatWarningsAsErrors Condition="'$(Configuration)' == 'Release'">true</TreatWarningsAsErrors>
10-
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
9+
<TreatWarningsAsErrors Condition="'$(Configuration)' == 'Release'">true</TreatWarningsAsErrors>
10+
<GeneratePackageOnBuild Condition="'$(Configuration)' == 'Release'">true</GeneratePackageOnBuild>
1111
<PackageTags>nuext;sqlite;database;ado.net;provider;interop;async</PackageTags>
1212
<Description>Provides SQLite database engine extensions.
1313

@@ -17,7 +17,7 @@ System.Data.SQLite.SQLiteDbConnection
1717
System.Data.SQLite.SQLiteDbContext
1818
System.Data.SQLite.SQLiteDbConverter
1919
System.Data.SQLite.SQLiteDbTransaction</Description>
20-
<Version>0.4.0</Version>
20+
<Version>0.4.1</Version>
2121
<RootNamespace />
2222
<GenerateDocumentationFile>True</GenerateDocumentationFile>
2323
<NoWarn>$(NoWarn);1591;NETSDK1233</NoWarn>
@@ -31,7 +31,7 @@ System.Data.SQLite.SQLiteDbTransaction</Description>
3131
</ItemGroup>
3232

3333
<ItemGroup Condition="'$(UseNuExtPackages)' == 'true'">
34-
<PackageReference Include="NuExt.System.Data" Version="0.4.0" />
34+
<PackageReference Include="NuExt.System.Data" Version="0.4.1" />
3535
</ItemGroup>
3636

3737
<ItemGroup Condition="'$(UseNuExtPackages)' == 'false'">

src/System/Data/SQLite/SQLiteDalBase.cs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,8 @@ protected sealed override SQLiteDbContext CreateDbContext()
5151
/// </exception>
5252
protected override ValueTask TryExecuteInDbContextAsync(SQLiteDbContext? context, Action<SQLiteDbContext> action, CancellationToken cancellationToken = default)
5353
{
54-
#if NET
5554
ArgumentNullException.ThrowIfNull(action);
56-
#else
57-
Throw.IfNull(action);
58-
#endif
55+
5956
if (context == null)
6057
{
6158
using var connection = CreateConnection();
@@ -95,11 +92,8 @@ protected override ValueTask TryExecuteInDbContextAsync(SQLiteDbContext? context
9592
/// </exception>
9693
protected override async ValueTask TryExecuteInDbContextAsync(SQLiteDbContext? context, Func<SQLiteDbContext, ValueTask> action, CancellationToken cancellationToken = default)
9794
{
98-
#if NET
9995
ArgumentNullException.ThrowIfNull(action);
100-
#else
101-
Throw.IfNull(action);
102-
#endif
96+
10397
if (context == null)
10498
{
10599
using var connection = CreateConnection();
@@ -140,11 +134,8 @@ await connection.AcquireLockAsync(async () =>
140134
/// </exception>
141135
protected override ValueTask<T> TryExecuteInDbContextAsync<T>(SQLiteDbContext? context, Func<SQLiteDbContext, T> func, CancellationToken cancellationToken = default)
142136
{
143-
#if NET
144137
ArgumentNullException.ThrowIfNull(func);
145-
#else
146-
Throw.IfNull(func);
147-
#endif
138+
148139
if (context == null)
149140
{
150141
using var connection = CreateConnection();
@@ -187,11 +178,8 @@ protected override ValueTask<T> TryExecuteInDbContextAsync<T>(SQLiteDbContext? c
187178
/// </exception>
188179
protected override async ValueTask<T> TryExecuteInDbContextAsync<T>(SQLiteDbContext? context, Func<SQLiteDbContext, ValueTask<T>> func, CancellationToken cancellationToken = default)
189180
{
190-
#if NET
191181
ArgumentNullException.ThrowIfNull(func);
192-
#else
193-
Throw.IfNull(func);
194-
#endif
182+
195183
if (context == null)
196184
{
197185
using var connection = CreateConnection();

src/System/Data/SQLite/SQLiteDbConnection.Adapters.cs

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@ public SQLiteDataAdapter CreateAdapter(SQLiteCommand command)
2121
{
2222
CheckDisposed();
2323
Debug.Assert(command != null, $"{nameof(command)} is null");
24-
#if NET6_0_OR_GREATER
2524
ArgumentNullException.ThrowIfNull(command);
26-
#else
27-
Throw.IfNull(command);
28-
#endif
25+
2926
return new SQLiteDataAdapter() { SelectCommand = command };
3027
}
3128

@@ -36,32 +33,21 @@ public SQLiteDataAdapter CreateAdapter(SQLiteCommand command)
3633
[MethodImpl(MethodImplOptions.AggressiveInlining)]
3734
public DataTable Select(string tableName, IEnumerable<string> fields, string? expr = null, CancellationToken cancellationToken = default, params SQLiteParameter[] parameters)
3835
{
39-
#if NET8_0_OR_GREATER
4036
ArgumentException.ThrowIfNullOrEmpty(tableName);
41-
#else
42-
Throw.IfNullOrEmpty(tableName);
43-
#endif
4437
return Select(CreateCommandSelect(tableName, fields, expr, parameters), cancellationToken);
4538
}
4639

4740
[MethodImpl(MethodImplOptions.AggressiveInlining)]
4841
public DataTable Select(string sql, CancellationToken cancellationToken = default, params SQLiteParameter[] parameters)
4942
{
50-
#if NET8_0_OR_GREATER
5143
ArgumentException.ThrowIfNullOrEmpty(sql);
52-
#else
53-
Throw.IfNullOrEmpty(sql);
54-
#endif
5544
return Select(CreateCommand(sql, parameters), cancellationToken);
5645
}
5746

5847
public DataTable Select(SQLiteCommand command, CancellationToken cancellationToken = default)
5948
{
60-
#if NET6_0_OR_GREATER
6149
ArgumentNullException.ThrowIfNull(command);
62-
#else
63-
Throw.IfNull(command);
64-
#endif
50+
6551
using var adapter = CreateAdapter();
6652
try
6753
{
@@ -84,32 +70,20 @@ public DataTable Select(SQLiteCommand command, CancellationToken cancellationTok
8470
[MethodImpl(MethodImplOptions.AggressiveInlining)]
8571
public (SQLiteDataAdapter Adapter, DataTable Table) SelectForUpdate(string tableName, IEnumerable<string> fields, string? expr = null, bool generateCommands = true, CancellationToken cancellationToken = default, params SQLiteParameter[] parameters)
8672
{
87-
#if NET8_0_OR_GREATER
8873
ArgumentException.ThrowIfNullOrEmpty(tableName);
89-
#else
90-
Throw.IfNullOrEmpty(tableName);
91-
#endif
9274
return SelectForUpdate(CreateCommandSelect(tableName, fields, expr, parameters), generateCommands, cancellationToken);
9375
}
9476

9577
[MethodImpl(MethodImplOptions.AggressiveInlining)]
9678
public (SQLiteDataAdapter Adapter, DataTable Table) SelectForUpdate(string sql, bool generateCommands = true, CancellationToken cancellationToken = default, params SQLiteParameter[] parameters)
9779
{
98-
#if NET8_0_OR_GREATER
9980
ArgumentException.ThrowIfNullOrEmpty(sql);
100-
#else
101-
Throw.IfNullOrEmpty(sql);
102-
#endif
10381
return SelectForUpdate(CreateCommand(sql, parameters), generateCommands, cancellationToken);
10482
}
10583

10684
public (SQLiteDataAdapter Adapter, DataTable Table) SelectForUpdate(SQLiteCommand command, bool generateCommands = true, CancellationToken cancellationToken = default)
10785
{
108-
#if NET6_0_OR_GREATER
10986
ArgumentNullException.ThrowIfNull(command);
110-
#else
111-
Throw.IfNull(command);
112-
#endif
11387
var adapter = CreateAdapter();
11488
try
11589
{
@@ -144,13 +118,8 @@ public DataTable Select(SQLiteCommand command, CancellationToken cancellationTok
144118

145119
public void Fill(SQLiteDataAdapter adapter, DataTable table, CancellationToken cancellationToken = default)
146120
{
147-
#if NET6_0_OR_GREATER
148121
ArgumentNullException.ThrowIfNull(adapter);
149122
ArgumentNullException.ThrowIfNull(table);
150-
#else
151-
Throw.IfNull(adapter);
152-
Throw.IfNull(table);
153-
#endif
154123

155124
AcquireLock(() => adapter.Fill(table), cancellationToken);
156125
}
@@ -161,13 +130,9 @@ public void Fill(SQLiteDataAdapter adapter, DataTable table, CancellationToken c
161130

162131
public int Update(SQLiteDataAdapter adapter, DataTable table, CancellationToken cancellationToken = default)
163132
{
164-
#if NET6_0_OR_GREATER
165133
ArgumentNullException.ThrowIfNull(adapter);
166134
ArgumentNullException.ThrowIfNull(table);
167-
#else
168-
Throw.IfNull(adapter);
169-
Throw.IfNull(table);
170-
#endif
135+
171136
//Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
172137
return AcquireLock(() => adapter.Update(table), cancellationToken);
173138
}

0 commit comments

Comments
 (0)