-
Notifications
You must be signed in to change notification settings - Fork 150
Expand file tree
/
Copy pathRepositoryBase.cs
More file actions
28 lines (24 loc) · 1.1 KB
/
RepositoryBase.cs
File metadata and controls
28 lines (24 loc) · 1.1 KB
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
// Copyright © 2017 Dmitry Sikorsky. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using ExtCore.Data.Abstractions;
using ExtCore.Data.Entities.Abstractions;
using Microsoft.EntityFrameworkCore;
namespace ExtCore.Data.EntityFramework;
/// <summary>
/// Implements the <see cref="IRepository">IRepository</see> interface and represents default repository behavior.
/// </summary>
/// <typeparam name="TEntity">The entity type this repository operates.</typeparam>
public abstract class RepositoryBase<TEntity> : IRepository where TEntity : class, IEntity
{
protected DbContext storageContext;
protected DbSet<TEntity> dbSet;
/// <summary>
/// Sets the Entity Framework storage context that represents the physical storage to work with.
/// </summary>
/// <param name="storageContext">The Entity Framework storage context to set.</param>
public void SetStorageContext(IStorageContext storageContext)
{
this.storageContext = storageContext as DbContext;
this.dbSet = this.storageContext.Set<TEntity>();
}
}