Y.SqlsugarRepository
1.0.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Y.SqlsugarRepository --version 1.0.1
NuGet\Install-Package Y.SqlsugarRepository -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Y.SqlsugarRepository" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Y.SqlsugarRepository --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Y.SqlsugarRepository, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Y.SqlsugarRepository as a Cake Addin #addin nuget:?package=Y.SqlsugarRepository&version=1.0.1 // Install Y.SqlsugarRepository as a Cake Tool #tool nuget:?package=Y.SqlsugarRepository&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
public override void ConfigerService(ConfigerServiceContext context)
{
//数据库配置
// base.ConfigerService(context);
var configuration = context.GetConfiguartion();
context.Services.AddSqlSugarClientAsScope(p =>
{
p.ConnectionString = configuration.GetSection("App:ConnectionString:Default").Value;
p.DbType = SqlSugar.DbType.SqlServer;
p.IsAutoCloseConnection = true;
p.ConfigureExternalServices = TableAttributeConfig.AddContextColumsConfigure();
});
context.Services.AddSingleton<IEntityManager, EntityManager>();
//添加数据库上下文AOP配置
context.Services.AddScoped<IDbAopProvider, DbAopProvider>();
Configure<DbConfigureOptions>(options =>
{
var config = configuration
.GetSection("App:DbConfigureOptions")
.Get<DbConfigureOptions>();
options.EnableAopLog = config.EnableAopLog;
options.EnableAopError = config.EnableAopError;
});
context.Services.AddRepository(provider =>
{
//添加数据库实体
provider.AddEntity<User>();
});
//数据库建库建表配置
Configure<DatabaseSetting>(p =>
{
//跳过建库建表
p.SikpBuildDatabase = true;
});
}
public override void LaterInitApplication(InitApplicationContext context)
{
var entityManager = context.ServiceProvider
.GetRequiredService<IEntityManager>();
//初始化数据库
entityManager.BuildDataBase();
}
//使用
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
//依赖注入
private readonly IBaseRepository<User, long> userRespo;
public HomeController(ILogger<HomeController> logger, IBaseRepository<User, long> baseRepository)
{
_logger = logger;
userRespo = baseRepository;
}
}
基于SqlSugar仓储注入类库
- 已实现仓储批量注入(已测试)
- 建库建表(已测试)
- 创建种子数据(已测试)
- 基于领域驱动设计带实现聚合根(待实现)
- 待完善仓储注入的扩展方法(已测试)
- 待完善数据库上下文注入扩展方法(已测试)
- 待实现统一的事务管理(Aop工作单元)(待实现)
- 待实现仓储的实现,可以自定义自己的仓储(待实现)
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
- SqlSugarCore (>= 5.1.4.94)
- System.Linq.Dynamic.Core (>= 1.3.4)
- Y.Module (>= 2.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Y.SqlsugarRepository:
Package | Downloads |
---|---|
WYG.Common
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.