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:
39
FreeSql.Repository/Extenssions/DependencyInjection.cs
Normal file
39
FreeSql.Repository/Extenssions/DependencyInjection.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using FreeSql;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace FreeSql {
|
||||
public static class FreeSqlRepositoryDependencyInjection {
|
||||
|
||||
public static IServiceCollection AddFreeRepository(this IServiceCollection services, Action<FluentDataFilter> globalDataFilter = null, params Assembly[] assemblies) {
|
||||
|
||||
DataFilterUtil._globalDataFilter = globalDataFilter;
|
||||
|
||||
services.AddScoped(typeof(IReadOnlyRepository<>), typeof(GuidRepository<>));
|
||||
services.AddScoped(typeof(IBasicRepository<>), typeof(GuidRepository<>));
|
||||
services.AddScoped(typeof(BaseRepository<>), typeof(GuidRepository<>));
|
||||
services.AddScoped(typeof(GuidRepository<>));
|
||||
|
||||
services.AddScoped(typeof(IReadOnlyRepository<,>), typeof(DefaultRepository<,>));
|
||||
services.AddScoped(typeof(IBasicRepository<,>), typeof(DefaultRepository<,>));
|
||||
services.AddScoped(typeof(BaseRepository<,>), typeof(DefaultRepository<,>));
|
||||
services.AddScoped(typeof(DefaultRepository<,>));
|
||||
|
||||
if (assemblies?.Any() == true) {
|
||||
foreach(var asse in assemblies) {
|
||||
foreach (var repos in asse.GetTypes().Where(a => a.IsAbstract == false && typeof(IRepository).IsAssignableFrom(a))) {
|
||||
|
||||
services.AddScoped(repos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user