forked from SharpRepository/SharpRepository
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIRepository.cs
More file actions
79 lines (69 loc) · 2.97 KB
/
IRepository.cs
File metadata and controls
79 lines (69 loc) · 2.97 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using SharpRepository.Repository.Transactions;
namespace SharpRepository.Repository
{
/// <summary>
/// Repository that acesses <typeparamref name="T"/> entities and has a primary key of type <typeparamref name="TKey"/>
/// </summary>
/// <typeparam name="T">The entity type that the repository acts on.</typeparam>
/// <typeparam name="TKey">The type of the primary key.</typeparam>
public interface IRepository<T, in TKey> : IRepositoryQueryable<T> where T : class
{
/// <summary>
/// Gets the specified entity of type <typeparamref name="T"/> from the repository by the primary key.
/// </summary>
/// <param name="key">The primary key.</param>
/// <returns>The entity that matches on the primary key</returns>
T Get(TKey key);
/// <summary>
/// Gets the specified entity of type <typeparamref name="T"/> from the repository by the primary key and maps it to the result of type <typeparamref name="TResult"/>.
/// </summary>
/// <typeparam name="TResult">The type of the result.</typeparam>
/// <param name="key">The primary key.</param>
/// <param name="selector">The mapping selector that returns the result type.</param>
/// <returns>The mapped entity based on the selector that matches on the primary key.</returns>
TResult Get<TResult>(TKey key, Expression<Func<T, TResult>> selector);
/// <summary>
/// Adds the specified entity.
/// </summary>
/// <param name="entity">The entity.</param>
void Add(T entity);
/// <summary>
/// Adds the specified entities.
/// </summary>
/// <param name="entities">The entities.</param>
void Add(IEnumerable<T> entities);
/// <summary>
/// Updates the specified entity.
/// </summary>
/// <param name="entity">The entity.</param>
void Update(T entity);
/// <summary>
/// Updates the specified entities.
/// </summary>
/// <param name="entities">The entities.</param>
void Update(IEnumerable<T> entities);
/// <summary>
/// Deletes the specified entity.
/// </summary>
/// <param name="entity">The entity.</param>
void Delete(T entity);
/// <summary>
/// Deletes the specified entities.
/// </summary>
/// <param name="entities">The entities.</param>
void Delete(IEnumerable<T> entities);
/// <summary>
/// Deletes the specified entity by the primary key.
/// </summary>
/// <param name="key">The primary key.</param>
void Delete(TKey key);
/// <summary>
/// Begins a batch mode process. This allows multiple operations against the repository with the ability to commit or rollback.
/// </summary>
/// <returns></returns>
IBatch<T> BeginBatch();
}
}