added DataContext.cs
This commit is contained in:
parent
4e3c3e6149
commit
7d06084dfb
6 changed files with 50 additions and 4 deletions
17
SurveyLib.Infrastructure.EFCore/Data/DataContext.cs
Normal file
17
SurveyLib.Infrastructure.EFCore/Data/DataContext.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using SurveyLib.Core.Models;
|
||||
|
||||
namespace SurveyLib.Infrastructure.EFCore.Data;
|
||||
|
||||
public class DataContext : DbContext
|
||||
{
|
||||
public DbSet<Survey> Surveys { get; set; }
|
||||
public DbSet<QuestionBase> Questions { get; set; }
|
||||
public DbSet<Completion> Completions { get; set; }
|
||||
public DbSet<Answer> Answers { get; set; }
|
||||
|
||||
public DataContext(DbContextOptions<DataContext> options) : base(options)
|
||||
{
|
||||
Database.EnsureCreated();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,19 @@
|
|||
using SurveyLib.Core.Models;
|
||||
using SurveyLib.Core.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SurveyLib.Infrastructure.EFCore.Data;
|
||||
|
||||
namespace SurveyLib.Infrastructure.EFCore.Repositories;
|
||||
|
||||
public class AnswerRepository : IAnswerRepository
|
||||
{
|
||||
private readonly DataContext _context;
|
||||
|
||||
public AnswerRepository(DataContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public Task<Answer>? GetByIdAsync(int id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
|
|
|||
|
|
@ -1,10 +1,18 @@
|
|||
using SurveyLib.Core.Models;
|
||||
using SurveyLib.Core.Repositories;
|
||||
using SurveyLib.Infrastructure.EFCore.Data;
|
||||
|
||||
namespace SurveyLib.Infrastructure.EFCore.Repositories;
|
||||
|
||||
public class CompletionRepository : ICompletionRepository
|
||||
{
|
||||
private readonly DataContext _context;
|
||||
|
||||
public CompletionRepository(DataContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public Task<Completion>? GetByIdAsync(int id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
|
|
|||
|
|
@ -1,10 +1,18 @@
|
|||
using SurveyLib.Core.Models;
|
||||
using SurveyLib.Core.Repositories;
|
||||
using SurveyLib.Infrastructure.EFCore.Data;
|
||||
|
||||
namespace SurveyLib.Infrastructure.EFCore.Repositories;
|
||||
|
||||
public class QuestionRepository : IQuestionRepository
|
||||
{
|
||||
private readonly DataContext _context;
|
||||
|
||||
public QuestionRepository(DataContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public Task<QuestionBase>? GetByIdAsync(int id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
|
|
|||
|
|
@ -1,10 +1,18 @@
|
|||
using SurveyLib.Core.Models;
|
||||
using SurveyLib.Core.Repositories;
|
||||
using SurveyLib.Infrastructure.EFCore.Data;
|
||||
|
||||
namespace SurveyLib.Infrastructure.EFCore.Repositories;
|
||||
|
||||
public class SurveyRepository : ISurveyRepository
|
||||
{
|
||||
private readonly DataContext _context;
|
||||
|
||||
public SurveyRepository(DataContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public Task<Survey>? GetByIdAsync(int id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
|
|
|||
|
|
@ -6,10 +6,6 @@
|
|||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Data\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.3" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue