Browse Source

feat: Add Workspace EFCore Repository Impl

pull/1421/head
colin 3 weeks ago
parent
commit
5168b9d375
  1. 2
      aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.Domain/LINGYUN/Abp/AIManagement/Workspaces/IWorkspaceRepository.cs
  2. 5
      aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.EntityFrameworkCore/LINGYUN/Abp/AIManagement/EntityFrameworkCore/AbpAIManagementEntityFrameworkCoreModule.cs
  3. 26
      aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.EntityFrameworkCore/LINGYUN/Abp/AIManagement/EntityFrameworkCore/EfCoreWorkspaceRepository.cs

2
aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.Domain/LINGYUN/Abp/AIManagement/Workspaces/IWorkspaceRepository.cs

@ -6,7 +6,7 @@ using Volo.Abp.Domain.Repositories;
namespace LINGYUN.Abp.AIManagement.Workspaces;
public interface IWorkspaceRepository : IBasicRepository<Workspace, Guid>
{
Task<Workspace> FindByNameAsync(
Task<Workspace?> FindByNameAsync(
string name,
CancellationToken cancellationToken = default);
}

5
aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.EntityFrameworkCore/LINGYUN/Abp/AIManagement/EntityFrameworkCore/AbpAIManagementEntityFrameworkCoreModule.cs

@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using LINGYUN.Abp.AIManagement.Workspaces;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Modularity;
@ -14,6 +15,8 @@ public class AbpAIManagementEntityFrameworkCoreModule : AbpModule
context.Services.AddAbpDbContext<AIManagementDbContext>(options =>
{
options.AddDefaultRepositories<IAIManagementDbContext>();
options.AddRepository<Workspace, EfCoreWorkspaceRepository>();
});
}
}

26
aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.EntityFrameworkCore/LINGYUN/Abp/AIManagement/EntityFrameworkCore/EfCoreWorkspaceRepository.cs

@ -0,0 +1,26 @@
using LINGYUN.Abp.AIManagement.Workspaces;
using Microsoft.EntityFrameworkCore;
using System;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
namespace LINGYUN.Abp.AIManagement.EntityFrameworkCore;
public class EfCoreWorkspaceRepository : EfCoreRepository<IAIManagementDbContext, Workspace, Guid>, IWorkspaceRepository
{
public EfCoreWorkspaceRepository(
IDbContextProvider<IAIManagementDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
public async virtual Task<Workspace?> FindByNameAsync(string name, CancellationToken cancellationToken = default)
{
return await (await GetQueryableAsync())
.Where(x => x.Name == name)
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); ;
}
}
Loading…
Cancel
Save