Working in migration to linq2SQL

This commit is contained in:
2020-09-28 21:23:11 +02:00
parent 552e9cc6df
commit 9bf37f5799
17 changed files with 194 additions and 876 deletions

View File

@ -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();
}
}
}