forked from SharpRepository/SharpRepository
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEfRepository.cs
More file actions
63 lines (58 loc) · 2.57 KB
/
EfRepository.cs
File metadata and controls
63 lines (58 loc) · 2.57 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System.Data.Entity;
using SharpRepository.Repository;
using SharpRepository.Repository.Caching;
namespace SharpRepository.EfRepository
{
public class EfRepository<T, TKey, TKey2> : EfCompoundKeyRepositoryBase<T, TKey, TKey2> where T : class
{
public EfRepository(DbContext dbContext, ICompoundKeyCachingStrategy<T, TKey, TKey2> cachingStrategy = null)
: base(dbContext, cachingStrategy)
{
}
}
public class EfRepository<T, TKey, TKey2, TKey3> : EfCompoundKeyRepositoryBase<T, TKey, TKey2, TKey3> where T : class, new()
{
public EfRepository(DbContext dbContext, ICompoundKeyCachingStrategy<T, TKey, TKey2, TKey3> cachingStrategy = null)
: base(dbContext, cachingStrategy)
{
}
}
public class EfCompoundKeyRepository<T> : EfCompoundKeyRepositoryBase<T> where T : class
{
public EfCompoundKeyRepository(DbContext dbContext, ICompoundKeyCachingStrategy<T> cachingStrategy = null)
: base(dbContext, cachingStrategy)
{
}
}
/// <summary>
/// Entity Framework repository layer
/// </summary>
/// <typeparam name="T">The Entity type</typeparam>
/// <typeparam name="TKey">The type of the primary key.</typeparam>
public class EfRepository<T, TKey> : EfRepositoryBase<T, TKey> where T : class
{
/// <summary>
/// Initializes a new instance of the <see cref="EfRepository<T, TKey>"/> class.
/// </summary>
/// <param name="dbContext">The Entity Framework DbContext.</param>
/// <param name="cachingStrategy">The caching strategy to use. Defaults to <see cref="NoCachingStrategy<T, TKey>" /></param>
public EfRepository(DbContext dbContext, ICachingStrategy<T, TKey> cachingStrategy = null) : base(dbContext, cachingStrategy)
{
}
}
/// <summary>
/// Entity Framework repository layer
/// </summary>
/// <typeparam name="T">The Entity type</typeparam>
public class EfRepository<T> : EfRepositoryBase<T, int>, IRepository<T> where T : class
{
/// <summary>
/// Initializes a new instance of the <see cref="EfRepository<T>"/> class.
/// </summary>
/// <param name="dbContext">The Entity Framework DbContext.</param>
/// <param name="cachingStrategy">The caching strategy to use. Defaults to <see cref="NoCachingStrategy<T, TKey>" /></param>
public EfRepository(DbContext dbContext, ICachingStrategy<T, int> cachingStrategy = null) : base(dbContext, cachingStrategy)
{
}
}
}