Working in migration to linq2SQL
This commit is contained in:
@ -1,53 +1,44 @@
|
||||
#nullable enable
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using UserService.DatabaseLayer.DataModels;
|
||||
using UserService.Infrastructure.DataModels;
|
||||
using DataModels;
|
||||
|
||||
namespace UserService.DatabaseLayer.Repositories
|
||||
{
|
||||
public class SecurityGroupsRepository : BaseRepository<SecurityGroup>, ISecurityGroupsRepository
|
||||
public class SecurityGroupsRepository : ISecurityGroupsRepository
|
||||
{
|
||||
public SecurityGroupsRepository() : base(x => x.SecurityGroups)
|
||||
/// <inheritdoc />
|
||||
public async Task<IReadOnlyList<SecurityGroup>> GetAllAsync(Expression<Func<SecurityGroup, bool>>? predicate = null, CancellationToken token = default)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override async Task<IReadOnlyList<SecurityGroup>> GetAllAsync(Expression<Func<SecurityGroup, bool>>? predicate = null, CancellationToken token = default)
|
||||
/// <inheritdoc />
|
||||
public async Task<SecurityGroup?> GetAsync(Expression<Func<SecurityGroup, bool>> predicate, CancellationToken token = default)
|
||||
{
|
||||
await using var db = new UserServiceDbContext();
|
||||
return await Context(db)
|
||||
.Include(x => x.Parent)
|
||||
.Include(x => x.Members)
|
||||
.ThenInclude(x=> x.AttachedMember)
|
||||
.WhereOrDefault(predicate)
|
||||
.ToListAsync(token).ConfigureAwait(false);
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override async Task<SecurityGroup?> GetAsync(Expression<Func<SecurityGroup, bool>> predicate, CancellationToken token = default)
|
||||
/// <inheritdoc />
|
||||
public async Task AddAsync(SecurityGroup entity, CancellationToken token = default)
|
||||
{
|
||||
await using var db = new UserServiceDbContext();
|
||||
return await Context(db)
|
||||
.Include(x => x.Parent)
|
||||
.Include(x => x.Members)
|
||||
.ThenInclude(x=> x.AttachedMember)
|
||||
.FirstOrDefaultAsync(predicate, token).ConfigureAwait(false);
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override async Task<bool> UpdateAsync(SecurityGroup entity, CancellationToken token = default)
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> UpdateAsync(SecurityGroup entity, CancellationToken token = default)
|
||||
{
|
||||
if (entity == null) throw new ArgumentNullException(nameof(entity));
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
await using var db = new UserServiceDbContext();
|
||||
Context(db).Update(entity);
|
||||
db.UserMembers.UpdateRange(entity.Members);
|
||||
var items = await db.SaveChangesAsync(token).ConfigureAwait(false);
|
||||
return items > 0;
|
||||
/// <inheritdoc />
|
||||
public async Task DeleteAsync(SecurityGroup entity, CancellationToken token = default)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user