控制器基类数据库非必选
This commit is contained in:
parent
256c00cfe2
commit
a9a592463d
|
@ -35,7 +35,7 @@ namespace Falcon.SugarApi.ApiDefinistions
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sugar数据库
|
/// Sugar数据库
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SugarDbContext SugarDb { get; set; }
|
public SugarDbContext? SugarDb { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 应用程序跟目录
|
/// 应用程序跟目录
|
||||||
|
@ -59,7 +59,7 @@ namespace Falcon.SugarApi.ApiDefinistions
|
||||||
protected ApiControllerBase(IServiceProvider service) {
|
protected ApiControllerBase(IServiceProvider service) {
|
||||||
this.Services = service;
|
this.Services = service;
|
||||||
this.Logger = service.GetService(typeof(ILogger<>).MakeGenericType(GetType())) as ILogger ?? throw new NullReferenceException("ILogger");
|
this.Logger = service.GetService(typeof(ILogger<>).MakeGenericType(GetType())) as ILogger ?? throw new NullReferenceException("ILogger");
|
||||||
this.SugarDb = service.GetService<SugarDbContext>() ?? throw new NullReferenceException("SugarDbContext");
|
this.SugarDb = service.GetService<SugarDbContext>();
|
||||||
this.Cache = service.GetService<IDistributedCache>();
|
this.Cache = service.GetService<IDistributedCache>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user