Line data Source code
1 : #region Copyright
2 : // // -----------------------------------------------------------------------
3 : // // <copyright company="Chinchilla Software Limited">
4 : // // Copyright Chinchilla Software Limited. All rights reserved.
5 : // // </copyright>
6 : // // -----------------------------------------------------------------------
7 : #endregion
8 :
9 : using System;
10 : using System.Collections.Generic;
11 : using Cqrs.DataStores;
12 : using Cqrs.Repositories.Queries;
13 :
14 : namespace Cqrs.Repositories
15 : {
16 : /// <summary>
17 : /// Provides basic repository methods for operations with an <see cref="IDataStore{TData}"/>.
18 : /// </summary>
19 : public interface IRepository<TQueryStrategy, TData>
20 : where TQueryStrategy : IQueryStrategy
21 : {
22 : /// <summary>
23 : /// Create the newly provided <paramref name="data"/> to storage.
24 : /// </summary>
25 1 : void Create(TData data);
26 :
27 : /// <summary>
28 : /// Create the newly provided <paramref name="data"/> to storage.
29 : /// </summary>
30 1 : void Create(IEnumerable<TData> data);
31 :
32 : /// <summary>
33 : /// Builds and executes the provided <paramref name="singleResultQuery"/>.
34 : /// </summary>
35 : /// <param name="singleResultQuery">The <see cref="ISingleResultQuery{TQueryStrategy,TData}"/> to build and execute.</param>
36 : /// <param name="throwExceptionWhenNoQueryResults">If true will throw an <see cref="Exception"/> if no data is found in storage.</param>
37 1 : ISingleResultQuery<TQueryStrategy, TData> Retrieve(ISingleResultQuery<TQueryStrategy, TData> singleResultQuery, bool throwExceptionWhenNoQueryResults = true);
38 :
39 : /// <summary>
40 : /// Builds and executes the provided <paramref name="resultQuery"/>.
41 : /// </summary>
42 : /// <param name="resultQuery">The <see cref="ICollectionResultQuery{TQueryStrategy,TData}"/> to build and execute.</param>
43 1 : ICollectionResultQuery<TQueryStrategy, TData> Retrieve(ICollectionResultQuery<TQueryStrategy, TData> resultQuery);
44 :
45 : /// <summary>
46 : /// Update the provided <paramref name="data"/> in storage.
47 : /// </summary>
48 1 : void Update(TData data);
49 :
50 : /// <summary>
51 : /// Will mark the <paramref name="data"/> as logically (or soft).
52 : /// </summary>
53 1 : void Delete(TData data);
54 :
55 : /// <summary>
56 : /// Delete all contents (normally by use of a truncate operation) in storage.
57 : /// </summary>
58 1 : void DeleteAll();
59 :
60 : /// <summary>
61 : /// Remove the provided <paramref name="data"/> from storage.
62 : /// </summary>
63 1 : void Destroy(TData data);
64 :
65 : /// <summary>
66 : /// Load the <typeparamref name="TData"/> from storage identified by the provided <paramref name="rsn"/>.
67 : /// </summary>
68 : /// <param name="rsn">The identifier if the <typeparamref name="TData"/> to load.</param>
69 : /// <param name="throwExceptionOnMissingEntity">If true will throw an <see cref="Exception"/> if no data is found in storage.</param>
70 1 : TData Load(Guid rsn, bool throwExceptionOnMissingEntity = true);
71 : }
72 : }
|