|
1 | | -using System; |
2 | | -using System.Collections.Generic; |
3 | | -using System.Linq; |
4 | | -using System.Linq.Expressions; |
5 | | -using SharpRepository.Repository.Queries; |
6 | | -using SharpRepository.Repository.Specifications; |
7 | | - |
8 | | -namespace SharpRepository.Repository |
9 | | -{ |
10 | | - public interface IRepositoryQueryable<T> : IDisposable where T : class |
11 | | - { |
12 | | - IQueryable<T> AsQueryable(); // don't want this public, just for POC |
13 | | - |
14 | | - IRepositoryQueryable<TResult> Join<TJoinKey, TInner, TResult>(IRepositoryQueryable<TInner> innerRepository, Expression<Func<T, TJoinKey>> outerKeySelector, Expression<Func<TInner, TJoinKey>> innerKeySelector, Expression<Func<T, TInner, TResult>> resultSelector) |
15 | | - where TInner : class |
16 | | - where TResult : class; |
17 | | - |
18 | | - /// <summary> |
19 | | - /// Gets all entities from the repository. |
20 | | - /// </summary> |
21 | | - /// <returns>All of the entities</returns> |
22 | | - IEnumerable<T> GetAll(); |
23 | | - |
24 | | - /// <summary> |
25 | | - /// Gets all entities from the repository and applies the query options (e.g. paging or sorting options) |
26 | | - /// </summary> |
27 | | - /// <param name="queryOptions">The query options to apply like paging or sorting.</param> |
28 | | - /// <returns></returns> |
29 | | - IEnumerable<T> GetAll(IQueryOptions<T> queryOptions); |
30 | | - |
31 | | - /// <summary> |
32 | | - /// Gets all entities from the repository, applies the query options (e.g. paging or sorting options) and maps to a new types based on the selector. |
33 | | - /// </summary> |
34 | | - /// <typeparam name="TResult">The type of the result.</typeparam> |
35 | | - /// <param name="selector">The mapping selector that returns the result type.</param> |
36 | | - /// <param name="queryOptions">The query options to apply like paging or sorting.</param> |
37 | | - /// <returns></returns> |
38 | | - IEnumerable<TResult> GetAll<TResult>(Expression<Func<T, TResult>> selector, IQueryOptions<T> queryOptions = null); |
39 | | - |
40 | | - /// <summary> |
41 | | - /// Finds a single entity that matches the predicate supplied using FirstOrDefault with an optional query option, like sorting options. |
42 | | - /// </summary> |
43 | | - /// <param name="predicate">The predicate used to match entities against.</param> |
44 | | - /// <param name="queryOptions">The query options to use (usually sorting) since this uses FirstOrDefault.</param> |
45 | | - /// <returns></returns> |
46 | | - T Find(Expression<Func<T, bool>> predicate, IQueryOptions<T> queryOptions = null); |
47 | | - |
48 | | - /// <summary> |
49 | | - /// Finds a single entity that matches the predicate supplied using FirstOrDefault with an optional query option, like sorting options, and maps it to a new type based on the selector. |
50 | | - /// </summary> |
51 | | - /// <typeparam name="TResult">The type of the result.</typeparam> |
52 | | - /// <param name="predicate">The predicate used to match entities against.</param> |
53 | | - /// <param name="selector">The mapping selector that returns the result type.</param> |
54 | | - /// <param name="queryOptions">The query options to use (usually sorting) since this uses FirstOrDefault.</param> |
55 | | - /// <returns></returns> |
56 | | - TResult Find<TResult>(Expression<Func<T, bool>> predicate, Expression<Func<T, TResult>> selector, IQueryOptions<T> queryOptions = null); |
57 | | - |
58 | | - /// <summary> |
59 | | - /// Finds a single entity that matches the specification criteria using FirstOrDefault with an optional query option, like sorting options. |
60 | | - /// </summary> |
61 | | - /// <param name="criteria">The specification criteria that is used for matching entities against.</param> |
62 | | - /// <param name="queryOptions">The query options to use (usually sorting) since this uses FirstOrDefault.</param> |
63 | | - /// <returns></returns> |
64 | | - T Find(ISpecification<T> criteria, IQueryOptions<T> queryOptions = null); |
65 | | - |
66 | | - /// <summary> |
67 | | - /// Finds a single entity that matches the specification criteria using FirstOrDefault with an optional query option, like sorting options, and maps to a new type based on the selector. |
68 | | - /// </summary> |
69 | | - /// <typeparam name="TResult">The type of the result.</typeparam> |
70 | | - /// <param name="criteria">The specification criteria that is used for matching entities against.</param> |
71 | | - /// <param name="selector">The mapping selector that returns the result type.</param> |
72 | | - /// <param name="queryOptions">The query options to use (usually sorting) since this uses FirstOrDefault.</param> |
73 | | - /// <returns></returns> |
74 | | - TResult Find<TResult>(ISpecification<T> criteria, Expression<Func<T, TResult>> selector, IQueryOptions<T> queryOptions = null); |
75 | | - |
76 | | - /// <summary> |
77 | | - /// Finds all entities that match the predicate with an optional query option applied (like paging or sorting). |
78 | | - /// </summary> |
79 | | - /// <param name="predicate">The predicate used to match entities against.</param> |
80 | | - /// <param name="queryOptions">The query options to apply like paging or sorting.</param> |
81 | | - /// <returns></returns> |
82 | | - IEnumerable<T> FindAll(Expression<Func<T, bool>> predicate, IQueryOptions<T> queryOptions = null); |
83 | | - |
84 | | - /// <summary> |
85 | | - /// Finds all entities that match the predicate with an optional query option applied (like paging or sorting), and maps to a new type based on the selector provided. |
86 | | - /// </summary> |
87 | | - /// <typeparam name="TResult">The type of the result.</typeparam> |
88 | | - /// <param name="predicate">The predicate used to match entities against.</param> |
89 | | - /// <param name="selector">The mapping selector that returns the result type.</param> |
90 | | - /// <param name="queryOptions">The query options to apply like paging or sorting.</param> |
91 | | - /// <returns></returns> |
92 | | - IEnumerable<TResult> FindAll<TResult>(Expression<Func<T, bool>> predicate, Expression<Func<T, TResult>> selector, IQueryOptions<T> queryOptions = null); |
93 | | - |
94 | | - /// <summary> |
95 | | - /// Finds all entities that match the specification criteria with an optional query option applied (like paging or sorting). |
96 | | - /// </summary> |
97 | | - /// <param name="criteria">The specification criteria that is used for matching entities against.</param> |
98 | | - /// <param name="queryOptions">The query options to apply like paging or sorting.</param> |
99 | | - /// <returns></returns> |
100 | | - IEnumerable<T> FindAll(ISpecification<T> criteria, IQueryOptions<T> queryOptions = null); |
101 | | - |
102 | | - /// <summary> |
103 | | - /// Finds all entities that match the specification criteria with an optional query option applied (like paging or sorting), and maps to a new type based on the selector provided. |
104 | | - /// </summary> |
105 | | - /// <typeparam name="TResult">The type of the result.</typeparam> |
106 | | - /// <param name="criteria">The specification criteria that is used for matching entities against.</param> |
107 | | - /// <param name="selector">The mapping selector that returns the result type.</param> |
108 | | - /// <param name="queryOptions">The query options to apply like paging or sorting.</param> |
109 | | - /// <returns></returns> |
110 | | - IEnumerable<TResult> FindAll<TResult>(ISpecification<T> criteria, Expression<Func<T, TResult>> selector, IQueryOptions<T> queryOptions = null); |
111 | | - } |
112 | | -} |
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq; |
| 4 | +using System.Linq.Expressions; |
| 5 | +using SharpRepository.Repository.Queries; |
| 6 | +using SharpRepository.Repository.Specifications; |
| 7 | + |
| 8 | +namespace SharpRepository.Repository |
| 9 | +{ |
| 10 | + public interface IRepositoryQueryable<T> : IEnumerable<T>, IDisposable where T : class |
| 11 | + { |
| 12 | + IQueryable<T> AsQueryable(); // don't want this public, just for POC |
| 13 | + |
| 14 | + IRepositoryQueryable<TResult> Join<TJoinKey, TInner, TResult>(IRepositoryQueryable<TInner> innerRepository, Expression<Func<T, TJoinKey>> outerKeySelector, Expression<Func<TInner, TJoinKey>> innerKeySelector, Expression<Func<T, TInner, TResult>> resultSelector) |
| 15 | + where TInner : class |
| 16 | + where TResult : class; |
| 17 | + |
| 18 | + /// <summary> |
| 19 | + /// Gets all entities from the repository. |
| 20 | + /// </summary> |
| 21 | + /// <returns>All of the entities</returns> |
| 22 | + IEnumerable<T> GetAll(); |
| 23 | + |
| 24 | + /// <summary> |
| 25 | + /// Gets all entities from the repository and applies the query options (e.g. paging or sorting options) |
| 26 | + /// </summary> |
| 27 | + /// <param name="queryOptions">The query options to apply like paging or sorting.</param> |
| 28 | + /// <returns></returns> |
| 29 | + IEnumerable<T> GetAll(IQueryOptions<T> queryOptions); |
| 30 | + |
| 31 | + /// <summary> |
| 32 | + /// Gets all entities from the repository, applies the query options (e.g. paging or sorting options) and maps to a new types based on the selector. |
| 33 | + /// </summary> |
| 34 | + /// <typeparam name="TResult">The type of the result.</typeparam> |
| 35 | + /// <param name="selector">The mapping selector that returns the result type.</param> |
| 36 | + /// <param name="queryOptions">The query options to apply like paging or sorting.</param> |
| 37 | + /// <returns></returns> |
| 38 | + IEnumerable<TResult> GetAll<TResult>(Expression<Func<T, TResult>> selector, IQueryOptions<T> queryOptions = null); |
| 39 | + |
| 40 | + /// <summary> |
| 41 | + /// Finds a single entity that matches the predicate supplied using FirstOrDefault with an optional query option, like sorting options. |
| 42 | + /// </summary> |
| 43 | + /// <param name="predicate">The predicate used to match entities against.</param> |
| 44 | + /// <param name="queryOptions">The query options to use (usually sorting) since this uses FirstOrDefault.</param> |
| 45 | + /// <returns></returns> |
| 46 | + T Find(Expression<Func<T, bool>> predicate, IQueryOptions<T> queryOptions = null); |
| 47 | + |
| 48 | + /// <summary> |
| 49 | + /// Finds a single entity that matches the predicate supplied using FirstOrDefault with an optional query option, like sorting options, and maps it to a new type based on the selector. |
| 50 | + /// </summary> |
| 51 | + /// <typeparam name="TResult">The type of the result.</typeparam> |
| 52 | + /// <param name="predicate">The predicate used to match entities against.</param> |
| 53 | + /// <param name="selector">The mapping selector that returns the result type.</param> |
| 54 | + /// <param name="queryOptions">The query options to use (usually sorting) since this uses FirstOrDefault.</param> |
| 55 | + /// <returns></returns> |
| 56 | + TResult Find<TResult>(Expression<Func<T, bool>> predicate, Expression<Func<T, TResult>> selector, IQueryOptions<T> queryOptions = null); |
| 57 | + |
| 58 | + /// <summary> |
| 59 | + /// Finds a single entity that matches the specification criteria using FirstOrDefault with an optional query option, like sorting options. |
| 60 | + /// </summary> |
| 61 | + /// <param name="criteria">The specification criteria that is used for matching entities against.</param> |
| 62 | + /// <param name="queryOptions">The query options to use (usually sorting) since this uses FirstOrDefault.</param> |
| 63 | + /// <returns></returns> |
| 64 | + T Find(ISpecification<T> criteria, IQueryOptions<T> queryOptions = null); |
| 65 | + |
| 66 | + /// <summary> |
| 67 | + /// Finds a single entity that matches the specification criteria using FirstOrDefault with an optional query option, like sorting options, and maps to a new type based on the selector. |
| 68 | + /// </summary> |
| 69 | + /// <typeparam name="TResult">The type of the result.</typeparam> |
| 70 | + /// <param name="criteria">The specification criteria that is used for matching entities against.</param> |
| 71 | + /// <param name="selector">The mapping selector that returns the result type.</param> |
| 72 | + /// <param name="queryOptions">The query options to use (usually sorting) since this uses FirstOrDefault.</param> |
| 73 | + /// <returns></returns> |
| 74 | + TResult Find<TResult>(ISpecification<T> criteria, Expression<Func<T, TResult>> selector, IQueryOptions<T> queryOptions = null); |
| 75 | + |
| 76 | + /// <summary> |
| 77 | + /// Finds all entities that match the predicate with an optional query option applied (like paging or sorting). |
| 78 | + /// </summary> |
| 79 | + /// <param name="predicate">The predicate used to match entities against.</param> |
| 80 | + /// <param name="queryOptions">The query options to apply like paging or sorting.</param> |
| 81 | + /// <returns></returns> |
| 82 | + IEnumerable<T> FindAll(Expression<Func<T, bool>> predicate, IQueryOptions<T> queryOptions = null); |
| 83 | + |
| 84 | + /// <summary> |
| 85 | + /// Finds all entities that match the predicate with an optional query option applied (like paging or sorting), and maps to a new type based on the selector provided. |
| 86 | + /// </summary> |
| 87 | + /// <typeparam name="TResult">The type of the result.</typeparam> |
| 88 | + /// <param name="predicate">The predicate used to match entities against.</param> |
| 89 | + /// <param name="selector">The mapping selector that returns the result type.</param> |
| 90 | + /// <param name="queryOptions">The query options to apply like paging or sorting.</param> |
| 91 | + /// <returns></returns> |
| 92 | + IEnumerable<TResult> FindAll<TResult>(Expression<Func<T, bool>> predicate, Expression<Func<T, TResult>> selector, IQueryOptions<T> queryOptions = null); |
| 93 | + |
| 94 | + /// <summary> |
| 95 | + /// Finds all entities that match the specification criteria with an optional query option applied (like paging or sorting). |
| 96 | + /// </summary> |
| 97 | + /// <param name="criteria">The specification criteria that is used for matching entities against.</param> |
| 98 | + /// <param name="queryOptions">The query options to apply like paging or sorting.</param> |
| 99 | + /// <returns></returns> |
| 100 | + IEnumerable<T> FindAll(ISpecification<T> criteria, IQueryOptions<T> queryOptions = null); |
| 101 | + |
| 102 | + /// <summary> |
| 103 | + /// Finds all entities that match the specification criteria with an optional query option applied (like paging or sorting), and maps to a new type based on the selector provided. |
| 104 | + /// </summary> |
| 105 | + /// <typeparam name="TResult">The type of the result.</typeparam> |
| 106 | + /// <param name="criteria">The specification criteria that is used for matching entities against.</param> |
| 107 | + /// <param name="selector">The mapping selector that returns the result type.</param> |
| 108 | + /// <param name="queryOptions">The query options to apply like paging or sorting.</param> |
| 109 | + /// <returns></returns> |
| 110 | + IEnumerable<TResult> FindAll<TResult>(ISpecification<T> criteria, Expression<Func<T, TResult>> selector, IQueryOptions<T> queryOptions = null); |
| 111 | + } |
| 112 | +} |
0 commit comments