## v0.3.16

- 修复 IInsert/IUpdate.NoneParameter() 设成了反作用的 bug;
- 修复 IDbFirst.GetTablesByDatabase() 默认数据库 bool 判断 bug;
- 增加 FreeSql.Repository 之 IUnitOfWork 实现,[查看参数资料](https://github.com/2881099/FreeSql/wiki/%e5%b7%a5%e4%bd%9c%e5%8d%95%e5%85%83);
- 增加 FreeSql.Repository 继承实现的仓储注入;
```csharp
builder.RegisterFreeRepository(
    filter => filter.Apply<Song>("test", a => a.Title == DateTime.Now.ToString() +
        Thread.CurrentThread.ManagedThreadId),
    this.GetType().Assembly
);
```
This commit is contained in:
28810
2019-03-14 16:17:40 +08:00
parent a2e7f62920
commit 2ab59201b0
23 changed files with 287 additions and 108 deletions

View File

@ -6,7 +6,7 @@ using System.Text;
using System.Linq;
namespace FreeSql {
public interface IDataFilter<TEntity> where TEntity : class {
public interface IDataFilter<TEntity> : IDisposable where TEntity : class {
IDataFilter<TEntity> Apply(string filterName, Expression<Func<TEntity, bool>> filterAndValidateExp);
@ -121,13 +121,20 @@ namespace FreeSql {
if (filterName == null) return false;
return _filters.TryGetValue(filterName, out var tryfi) ? tryfi.IsEnabled : false;
}
~DataFilter() {
this.Dispose();
}
public void Dispose() {
_filters.Clear();
}
}
public class GlobalDataFilter {
public class FluentDataFilter : IDisposable {
internal List<(Type type, string name, LambdaExpression exp)> _filters = new List<(Type type, string name, LambdaExpression exp)>();
public GlobalDataFilter Apply<TEntity>(string filterName, Expression<Func<TEntity, bool>> filterAndValidateExp) where TEntity : class {
public FluentDataFilter Apply<TEntity>(string filterName, Expression<Func<TEntity, bool>> filterAndValidateExp) where TEntity : class {
if (filterName == null)
throw new ArgumentNullException(nameof(filterName));
if (filterAndValidateExp == null) return this;
@ -135,5 +142,12 @@ namespace FreeSql {
_filters.Add((typeof(TEntity), filterName, filterAndValidateExp));
return this;
}
~FluentDataFilter() {
this.Dispose();
}
public void Dispose() {
_filters.Clear();
}
}
}