Skip to content

Commit

Permalink
chore: 更新依赖包
Browse files Browse the repository at this point in the history
  • Loading branch information
ArgoZhang committed Apr 23, 2024
1 parent 8a17999 commit 388b745
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BootstrapBlazor" Version="8.1.0" />
<PackageReference Include="BootstrapBlazor" Version="8.4.8-beta03" />
<PackageReference Include="BootstrapBlazor.DataAccess.SqlSugar" Version="8.00" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="BootstrapBlazor" Version="7.10.7" />
<PackageReference Include="BootstrapBlazor" Version="8.4.8-beta03" />
<PackageReference Include="BootstrapBlazor.DataAccess.EntityFrameworkCore" Version="7.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.11" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,8 @@ namespace BootstrapAdmin.DataAccess.EFCore.Services;
/// <summary>
/// EFCore ORM 的 IDataService 接口实现
/// </summary>
class DefaultDataService<TModel> : DataServiceBase<TModel> where TModel : class, new()
class DefaultDataService<TModel>(IDbContextFactory<BootstrapAdminContext> factory) : DataServiceBase<TModel> where TModel : class, new()
{
private IDbContextFactory<BootstrapAdminContext> DbFactory { get; }

/// <summary>
/// 构造函数
/// </summary>
public DefaultDataService(IDbContextFactory<BootstrapAdminContext> factory) => DbFactory = factory;

/// <summary>
/// 删除方法
/// </summary>
Expand All @@ -28,7 +21,7 @@ public override async Task<bool> DeleteAsync(IEnumerable<TModel> models)
{
// 通过模型获取主键列数据
// 支持批量删除
var context = DbFactory.CreateDbContext();
using var context = factory.CreateDbContext();
context.RemoveRange(models);
return await context.SaveChangesAsync() > 0;
}
Expand All @@ -41,7 +34,7 @@ public override async Task<bool> DeleteAsync(IEnumerable<TModel> models)
/// <returns></returns>
public override async Task<bool> SaveAsync(TModel model, ItemChangedType changedType)
{
var context = DbFactory.CreateDbContext();
using var context = factory.CreateDbContext();
if (changedType == ItemChangedType.Add)
{
context.Entry(model).State = EntityState.Added;
Expand All @@ -60,7 +53,7 @@ public override async Task<bool> SaveAsync(TModel model, ItemChangedType changed
/// <returns></returns>
public override Task<QueryData<TModel>> QueryAsync(QueryPageOptions option)
{
var context = DbFactory.CreateDbContext();
using var context = factory.CreateDbContext();
var ret = new QueryData<TModel>()
{
IsSorted = true,
Expand Down

0 comments on commit 388b745

Please sign in to comment.