mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
- 调整 Repository 接口定义,合并为一个 IBaseRepository;
This commit is contained in:
@ -1,29 +1,36 @@
|
||||
#if netcoreapp
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace FreeSql
|
||||
{
|
||||
public static class FreeSqlRepositoryDependencyInjection
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 批量注入 Repository,可以参考代码自行调整
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
/// <param name="globalDataFilter"></param>
|
||||
/// <param name="assemblies"></param>
|
||||
/// <returns></returns>
|
||||
public static IServiceCollection AddFreeRepository(this IServiceCollection services, Action<FluentDataFilter> globalDataFilter = null, params Assembly[] assemblies)
|
||||
{
|
||||
if (globalDataFilter != null)
|
||||
{
|
||||
DataFilterUtil._globalDataFilter = globalDataFilter;
|
||||
//如果看到了这里的代码,想自己调整,但因为 _globalDataFilter 是内部属性,无法修改?
|
||||
//请考虑改用 fsql.GlobalFilter.Apply
|
||||
}
|
||||
|
||||
DataFilterUtil._globalDataFilter = globalDataFilter;
|
||||
|
||||
services.AddScoped(typeof(IReadOnlyRepository<>), typeof(GuidRepository<>));
|
||||
services.AddScoped(typeof(IBasicRepository<>), typeof(GuidRepository<>));
|
||||
services.AddScoped(typeof(IBaseRepository<>), 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(IBaseRepository<,>), typeof(DefaultRepository<,>));
|
||||
services.AddScoped(typeof(BaseRepository<,>), typeof(DefaultRepository<,>));
|
||||
services.AddScoped(typeof(DefaultRepository<,>));
|
||||
|
||||
if (assemblies?.Any() == true)
|
||||
foreach (var asse in assemblies)
|
||||
|
Reference in New Issue
Block a user