blob: 15f058ccf2ef9bf650732a78aba80145d3a88cda (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
using Microsoft.EntityFrameworkCore;
namespace MyDarling.Models
{
public class MyDarlingRepository : IRepository
{
private DataContext DbContext { get; }
public MyDarlingRepository(IServiceProvider provider)
{
DbContext = provider.CreateScope().ServiceProvider.GetRequiredService<DataContext>();
}
public IQueryable<UnderwearBundle> Bundles => DbContext.UnderwearBundles.Include(b => b.Figures);
public void Add(UnderwearBundle b)
{
DbContext.UnderwearBundles.Add(b);
DbContext.SaveChanges();
}
public void Remove(UnderwearBundle b)
{
DbContext.UnderwearBundles.Remove(b);
DbContext.SaveChanges();
}
public void Save()
{
DbContext.SaveChanges();
}
}
}
|