mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
debug Destructor #131
This commit is contained in:
@ -4,6 +4,7 @@ using System.Collections.Concurrent;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
|
||||
namespace FreeSql
|
||||
{
|
||||
@ -200,11 +201,10 @@ namespace FreeSql
|
||||
#endregion
|
||||
|
||||
~DbContext() => this.Dispose();
|
||||
bool _isdisposed = false;
|
||||
int _disposeCounter;
|
||||
public void Dispose()
|
||||
{
|
||||
if (_isdisposed) return;
|
||||
_isdisposed = true;
|
||||
if (Interlocked.Increment(ref _disposeCounter) != 1) return;
|
||||
try
|
||||
{
|
||||
_actions.Clear();
|
||||
|
@ -7,6 +7,7 @@ using System.Collections.Concurrent;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
|
||||
namespace FreeSql
|
||||
{
|
||||
@ -36,11 +37,10 @@ namespace FreeSql
|
||||
}
|
||||
|
||||
~DbSet() => this.Dispose();
|
||||
bool _isdisposed = false;
|
||||
int _disposeCounter;
|
||||
public void Dispose()
|
||||
{
|
||||
if (_isdisposed) return;
|
||||
_isdisposed = true;
|
||||
if (Interlocked.Increment(ref _disposeCounter) != 1) return;
|
||||
try
|
||||
{
|
||||
this._dicUpdateTimes.Clear();
|
||||
|
@ -144,10 +144,7 @@ namespace FreeSql
|
||||
return _filters.TryGetValue(filterName, out var tryfi) ? tryfi.IsEnabled : false;
|
||||
}
|
||||
|
||||
~DataFilter()
|
||||
{
|
||||
this.Dispose();
|
||||
}
|
||||
~DataFilter() => this.Dispose();
|
||||
public void Dispose()
|
||||
{
|
||||
_filters.Clear();
|
||||
@ -169,10 +166,7 @@ namespace FreeSql
|
||||
return this;
|
||||
}
|
||||
|
||||
~FluentDataFilter()
|
||||
{
|
||||
this.Dispose();
|
||||
}
|
||||
~FluentDataFilter() => this.Dispose();
|
||||
public void Dispose()
|
||||
{
|
||||
_filters.Clear();
|
||||
|
@ -3,6 +3,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FreeSql
|
||||
@ -42,11 +43,10 @@ namespace FreeSql
|
||||
}
|
||||
|
||||
~BaseRepository() => this.Dispose();
|
||||
bool _isdisposed = false;
|
||||
int _disposeCounter;
|
||||
public void Dispose()
|
||||
{
|
||||
if (_isdisposed) return;
|
||||
_isdisposed = true;
|
||||
if (Interlocked.Increment(ref _disposeCounter) != 1) return;
|
||||
try
|
||||
{
|
||||
_dbsetPriv?.Dispose();
|
||||
|
@ -105,18 +105,20 @@ namespace FreeSql
|
||||
|
||||
public DbContext.EntityChangeReport EntityChangeReport { get; } = new DbContext.EntityChangeReport();
|
||||
|
||||
~UnitOfWork()
|
||||
{
|
||||
this.Dispose();
|
||||
}
|
||||
bool _isdisposed = false;
|
||||
~UnitOfWork() => this.Dispose();
|
||||
int _disposeCounter;
|
||||
public void Dispose()
|
||||
{
|
||||
if (_isdisposed) return;
|
||||
_isdisposed = true;
|
||||
this.Rollback();
|
||||
this.Close();
|
||||
GC.SuppressFinalize(this);
|
||||
if (Interlocked.Increment(ref _disposeCounter) != 1) return;
|
||||
try
|
||||
{
|
||||
this.Rollback();
|
||||
this.Close();
|
||||
}
|
||||
finally
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user