mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
## v0.3.27
- 增加 行级锁功能,适用修改实体; - 增加 FreeSql.Repository 默认依赖注入的方式,同时保留原有 Autofac; - 优化 FreeSql.Repository Insert 逻辑,参考了 FreeSql.DbContext; - 优化 FreeSql.IUpdate 参照 IInsert 对大批量更新,拆分执行; - 修复 FreeSql.IInsert ClearData 重复利用的 bug(使用 IgnoreColumns 进行大批量插入时会发生);
This commit is contained in:
48
FreeSql.Repository/Extenssions/AutofacDependencyInjection.cs
Normal file
48
FreeSql.Repository/Extenssions/AutofacDependencyInjection.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using Autofac;
|
||||
using FreeSql;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
|
||||
public static class FreeSqlRepositoryAutofacExtenssions {
|
||||
|
||||
/// <summary>
|
||||
/// 注册 FreeSql.Repository 包括 泛型、继承实现的仓储
|
||||
/// </summary>
|
||||
/// <param name="builder"></param>
|
||||
/// <param name="globalDataFilter">全局过滤设置</param>
|
||||
/// <param name="assemblies">继承实现的仓储,所在的程序集</param>
|
||||
public static void RegisterFreeRepository(this ContainerBuilder builder, Action<FluentDataFilter> globalDataFilter = null, params Assembly[] assemblies) =>
|
||||
RegisterFreeRepositoryPrivate(builder, globalDataFilter, assemblies);
|
||||
|
||||
static void RegisterFreeRepositoryPrivate(ContainerBuilder builder, Action<FluentDataFilter> globalDataFilter, params Assembly[] assemblies) {
|
||||
|
||||
DataFilterUtil._globalDataFilter = globalDataFilter;
|
||||
|
||||
builder.RegisterGeneric(typeof(GuidRepository<>)).As(
|
||||
typeof(GuidRepository<>),
|
||||
typeof(BaseRepository<>),
|
||||
typeof(IBasicRepository<>),
|
||||
typeof(IReadOnlyRepository<>)
|
||||
).OnActivating(a => {
|
||||
//Utils.SetRepositoryDataFilter(a.Instance);
|
||||
}).InstancePerDependency();
|
||||
|
||||
builder.RegisterGeneric(typeof(DefaultRepository<,>)).As(
|
||||
typeof(DefaultRepository<,>),
|
||||
typeof(BaseRepository<,>),
|
||||
typeof(IBasicRepository<,>),
|
||||
typeof(IReadOnlyRepository<,>)
|
||||
).OnActivating(a => {
|
||||
//Utils.SetRepositoryDataFilter(a.Instance);
|
||||
}).InstancePerDependency();
|
||||
|
||||
builder.RegisterAssemblyTypes(assemblies).Where(a => {
|
||||
return typeof(IRepository).IsAssignableFrom(a);
|
||||
}).InstancePerDependency();
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user