Skip to content

Commit

Permalink
iadd idisposable to data provider for non asyn dispose folks (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
dibiancoj authored Nov 2, 2024
1 parent 56c068a commit 0b524ff
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Src/LibraryCore.Core/DataProviders/IDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace LibraryCore.Core.DataProviders;

public interface IDataProvider
public interface IDataProvider : IDisposable, IAsyncDisposable
{
Task<bool> CanConnectToDatabaseAsync();
Task CloseConnectionAsync();
Expand Down
23 changes: 22 additions & 1 deletion Src/LibraryCore.Core/DataProviders/SqlDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace LibraryCore.Core.DataProviders;

[ExcludeFromCodeCoverage(Justification = "Tested In Integration Project. Using this as a 1 off")]
public class SqlDataProvider : IDataProvider, IAsyncDisposable
public class SqlDataProvider : IDataProvider, IAsyncDisposable, IDisposable
{

#region Constructor
Expand Down Expand Up @@ -259,6 +259,27 @@ protected virtual async ValueTask DisposeAsyncInternal(bool disposing)
}
}

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
if (Disposed)
{
return;
}

if (disposing)
{
ConnSql.Close();
ConnSql.Dispose();
Disposed = true;
}
}

#endregion

}
2 changes: 1 addition & 1 deletion Src/LibraryCore.Core/LibraryCore.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<Authors>Jason DiBianco</Authors>
<Description>.NetCore Common Library</Description>
<Version>9.3.0</Version>
<Version>9.4.0</Version>
<RepositoryUrl>https://github.com/dibiancoj/LibraryCore</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Title>LibraryCore - Core</Title>
Expand Down

0 comments on commit 0b524ff

Please sign in to comment.