refactor: use wrap DbContext
This commit is contained in:
parent
53a0439edb
commit
f79c7c7db9
@ -1,17 +1,18 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||||
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
using Mirea.Api.DataAccess.Persistence.Common;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
||||||
|
|
||||||
public class CampusDbContext(DbContextOptions<CampusDbContext> options) : DbContext(options), ICampusDbContext
|
public class CampusDbContext(DbContextOptions<CampusDbContext> options) : BaseDbContext<CampusDbContext>(options), ICampusDbContext
|
||||||
{
|
{
|
||||||
public DbSet<Campus> Campuses { get; set; } = null!;
|
public DbSet<Campus> Campuses { get; set; } = null!;
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
modelBuilder.ApplyConfiguration(new CampusConfiguration());
|
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,17 +1,18 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||||
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
using Mirea.Api.DataAccess.Persistence.Common;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
||||||
|
|
||||||
public class DisciplineDbContext(DbContextOptions<DisciplineDbContext> options) : DbContext(options), IDisciplineDbContext
|
public sealed class DisciplineDbContext(DbContextOptions<DisciplineDbContext> options) : BaseDbContext<DisciplineDbContext>(options), IDisciplineDbContext
|
||||||
{
|
{
|
||||||
public DbSet<Discipline> Disciplines { get; set; } = null!;
|
public DbSet<Discipline> Disciplines { get; set; } = null!;
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
modelBuilder.ApplyConfiguration(new DisciplineConfiguration());
|
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,17 +1,18 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||||
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
using Mirea.Api.DataAccess.Persistence.Common;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
||||||
|
|
||||||
public class FacultyDbContext(DbContextOptions<FacultyDbContext> options) : DbContext(options), IFacultyDbContext
|
public sealed class FacultyDbContext(DbContextOptions<FacultyDbContext> options) : BaseDbContext<FacultyDbContext>(options), IFacultyDbContext
|
||||||
{
|
{
|
||||||
public DbSet<Faculty> Faculties { get; set; } = null!;
|
public DbSet<Faculty> Faculties { get; set; } = null!;
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
modelBuilder.ApplyConfiguration(new FacultyConfiguration());
|
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,17 +1,18 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||||
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
using Mirea.Api.DataAccess.Persistence.Common;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
||||||
|
|
||||||
public class GroupDbContext(DbContextOptions<GroupDbContext> options) : DbContext(options), IGroupDbContext
|
public sealed class GroupDbContext(DbContextOptions<GroupDbContext> options) : BaseDbContext<GroupDbContext>(options), IGroupDbContext
|
||||||
{
|
{
|
||||||
public DbSet<Group> Groups { get; set; } = null!;
|
public DbSet<Group> Groups { get; set; } = null!;
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
modelBuilder.ApplyConfiguration(new GroupConfiguration());
|
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,17 +1,18 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||||
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
using Mirea.Api.DataAccess.Persistence.Common;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
||||||
|
|
||||||
public class LectureHallDbContext(DbContextOptions<LectureHallDbContext> options) : DbContext(options), ILectureHallDbContext
|
public sealed class LectureHallDbContext(DbContextOptions<LectureHallDbContext> options) : BaseDbContext<LectureHallDbContext>(options), ILectureHallDbContext
|
||||||
{
|
{
|
||||||
public DbSet<LectureHall> LectureHalls { get; set; } = null!;
|
public DbSet<LectureHall> LectureHalls { get; set; } = null!;
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
modelBuilder.ApplyConfiguration(new LectureHallConfiguration());
|
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,17 +1,18 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||||
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
using Mirea.Api.DataAccess.Persistence.Common;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
||||||
|
|
||||||
public class LessonAssociationDbContext(DbContextOptions<LessonAssociationDbContext> options) : DbContext(options), ILessonAssociationDbContext
|
public sealed class LessonAssociationDbContext(DbContextOptions<LessonAssociationDbContext> options) : BaseDbContext<LessonAssociationDbContext>(options), ILessonAssociationDbContext
|
||||||
{
|
{
|
||||||
public DbSet<LessonAssociation> LessonAssociations { get; set; } = null!;
|
public DbSet<LessonAssociation> LessonAssociations { get; set; } = null!;
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
modelBuilder.ApplyConfiguration(new LessonAssociationConfiguration());
|
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,17 +1,18 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||||
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
using Mirea.Api.DataAccess.Persistence.Common;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
||||||
|
|
||||||
public class LessonDbContext(DbContextOptions<LessonDbContext> options) : DbContext(options), ILessonDbContext
|
public sealed class LessonDbContext(DbContextOptions<LessonDbContext> options) : BaseDbContext<LessonDbContext>(options), ILessonDbContext
|
||||||
{
|
{
|
||||||
public DbSet<Lesson> Lessons { get; set; } = null!;
|
public DbSet<Lesson> Lessons { get; set; } = null!;
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
modelBuilder.ApplyConfiguration(new LessonConfiguration());
|
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,17 +1,18 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||||
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
using Mirea.Api.DataAccess.Persistence.Common;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
||||||
|
|
||||||
public class ProfessorDbContext(DbContextOptions<ProfessorDbContext> options) : DbContext(options), IProfessorDbContext
|
public sealed class ProfessorDbContext(DbContextOptions<ProfessorDbContext> options) : BaseDbContext<ProfessorDbContext>(options), IProfessorDbContext
|
||||||
{
|
{
|
||||||
public DbSet<Professor> Professors { get; set; } = null!;
|
public DbSet<Professor> Professors { get; set; } = null!;
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
modelBuilder.ApplyConfiguration(new ProfessorConfiguration());
|
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,17 +1,18 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||||
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
using Mirea.Api.DataAccess.Persistence.Common;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
||||||
|
|
||||||
public class SpecificWeekDbContext(DbContextOptions<SpecificWeekDbContext> options) : DbContext(options), ISpecificWeekDbContext
|
public sealed class SpecificWeekDbContext(DbContextOptions<SpecificWeekDbContext> options) : BaseDbContext<SpecificWeekDbContext>(options), ISpecificWeekDbContext
|
||||||
{
|
{
|
||||||
public DbSet<SpecificWeek> SpecificWeeks { get; set; } = null!;
|
public DbSet<SpecificWeek> SpecificWeeks { get; set; } = null!;
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
modelBuilder.ApplyConfiguration(new SpecificWeekConfiguration());
|
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,17 +1,18 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||||
using Mirea.Api.DataAccess.Domain.Schedule;
|
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||||
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
using Mirea.Api.DataAccess.Persistence.Common;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
namespace Mirea.Api.DataAccess.Persistence.Contexts.Schedule;
|
||||||
|
|
||||||
public class TypeOfOccupationDbContext(DbContextOptions<TypeOfOccupationDbContext> options) : DbContext(options), ITypeOfOccupationDbContext
|
public sealed class TypeOfOccupationDbContext(DbContextOptions<TypeOfOccupationDbContext> options) : BaseDbContext<TypeOfOccupationDbContext>(options), ITypeOfOccupationDbContext
|
||||||
{
|
{
|
||||||
public DbSet<TypeOfOccupation> TypeOfOccupations { get; set; } = null!;
|
public DbSet<TypeOfOccupation> TypeOfOccupations { get; set; } = null!;
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
modelBuilder.ApplyConfiguration(new TypeOfOccupationConfiguration());
|
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user