-
Notifications
You must be signed in to change notification settings - Fork 935
/
Copy pathIMultiCriteria.cs
187 lines (164 loc) · 7.1 KB
/
IMultiCriteria.cs
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
using System;
using System.Collections;
using NHibernate.Criterion;
using NHibernate.Impl;
using NHibernate.Transform;
namespace NHibernate
{
/// <summary>
/// Combines several queries into a single DB call
/// </summary>
// Since v5.2
[Obsolete("Use Multi.IQueryBatch instead, obtainable with ISession.CreateQueryBatch.")]
public partial interface IMultiCriteria
{
/// <summary>
/// Get all the results
/// </summary>
IList List();
/// <summary>
/// Adds the specified criteria to the query. The result will be contained in a <see cref="System.Collections.Generic.List{T}"/>
/// </summary>
/// <param name="resultGenericListType">Return results in a <see cref="System.Collections.Generic.List{resultGenericListType}"/></param>
/// <param name="criteria">The criteria.</param>
/// <returns></returns>
IMultiCriteria Add(System.Type resultGenericListType, ICriteria criteria);
/// <summary>
/// Adds the specified criteria to the query. The result will be contained in a <see cref="System.Collections.Generic.List{T}"/>
/// </summary>
/// <param name="criteria">The criteria.</param>
/// <returns></returns>
IMultiCriteria Add<T>(ICriteria criteria);
/// <summary>
/// Adds the specified criteria to the query, and associates it with the given key. The result will be contained in a <see cref="System.Collections.Generic.List{T}"/>
/// </summary>
/// <param name="key">The key</param>
/// <param name="criteria">The criteria</param>
/// <returns></returns>
IMultiCriteria Add<T>(string key, ICriteria criteria);
/// <summary>
/// Adds the specified detached criteria. The result will be contained in a <see cref="System.Collections.Generic.List{T}"/>
/// </summary>
/// <param name="detachedCriteria">The detached criteria.</param>
/// <returns></returns>
IMultiCriteria Add<T>(DetachedCriteria detachedCriteria);
/// <summary>
/// Adds the specified detached criteria, and associates it with the given key. The result will be contained in a <see cref="System.Collections.Generic.List{T}"/>
/// </summary>
/// <param name="key">The key</param>
/// <param name="detachedCriteria">The detached criteria</param>
/// <returns></returns>
IMultiCriteria Add<T>(string key, DetachedCriteria detachedCriteria);
/// <summary>
/// Adds the specified criteria to the query
/// </summary>
/// <param name="criteria">The criteria.</param>
/// <returns></returns>
IMultiCriteria Add(ICriteria criteria);
/// <summary>
/// Adds the specified criteria to the query, and associates it with the given key
/// </summary>
/// <param name="key">The key</param>
/// <param name="criteria">The criteria</param>
/// <returns></returns>
IMultiCriteria Add(string key, ICriteria criteria);
/// <summary>
/// Adds the specified detached criteria.
/// </summary>
/// <param name="detachedCriteria">The detached criteria.</param>
/// <returns></returns>
IMultiCriteria Add(DetachedCriteria detachedCriteria);
/// <summary>
/// Adds the specified detached criteria, and associates it with the given key
/// </summary>
/// <param name="key">The key</param>
/// <param name="detachedCriteria">The detached criteria</param>
/// <returns></returns>
IMultiCriteria Add(string key, DetachedCriteria detachedCriteria);
/// <summary>
/// Adds the specified IQueryOver to the query. The result will be contained in a <see cref="System.Collections.Generic.List{resultGenericListType}"/>
/// </summary>
/// <param name="resultGenericListType">Return results in a <see cref="System.Collections.Generic.List{resultGenericListType}"/></param>
/// <param name="queryOver">The IQueryOver.</param>
/// <returns></returns>
IMultiCriteria Add(System.Type resultGenericListType, IQueryOver queryOver);
/// <summary>
/// Adds the specified IQueryOver to the query. The result will be contained in a <see cref="System.Collections.Generic.List{T}"/>
/// </summary>
/// <param name="queryOver">The IQueryOver.</param>
/// <returns></returns>
IMultiCriteria Add<T>(IQueryOver<T> queryOver);
/// <summary>
/// Adds the specified IQueryOver to the query. The result will be contained in a <see cref="System.Collections.Generic.List{U}"/>
/// </summary>
/// <param name="queryOver">The IQueryOver.</param>
/// <returns></returns>
IMultiCriteria Add<U>(IQueryOver queryOver);
/// <summary>
/// Adds the specified IQueryOver to the query, and associates it with the given key. The result will be contained in a <see cref="System.Collections.Generic.List{T}"/>
/// </summary>
/// <param name="key">The key</param>
/// <param name="queryOver">The IQueryOver</param>
/// <returns></returns>
IMultiCriteria Add<T>(string key, IQueryOver<T> queryOver);
/// <summary>
/// Adds the specified IQueryOver to the query, and associates it with the given key. The result will be contained in a <see cref="System.Collections.Generic.List{U}"/>
/// </summary>
/// <param name="key">The key</param>
/// <param name="queryOver">The IQueryOver</param>
/// <returns></returns>
IMultiCriteria Add<U>(string key, IQueryOver queryOver);
/// <summary>
/// Sets whatever this criteria is cacheable.
/// </summary>
/// <param name="cachable">if set to <c>true</c> [cachable].</param>
IMultiCriteria SetCacheable(bool cachable);
///<summary>
/// Set the cache region for the criteria
///</summary>
///<param name="region">The region</param>
///<returns></returns>
IMultiCriteria SetCacheRegion(string region);
///<summary>
/// Force a cache refresh
///</summary>
///<param name="forceRefresh"></param>
///<returns></returns>
IMultiCriteria ForceCacheRefresh(bool forceRefresh);
/// <summary>
/// Sets the result transformer for all the results in this mutli criteria instance
/// </summary>
/// <param name="resultTransformer">The result transformer.</param>
/// <returns></returns>
IMultiCriteria SetResultTransformer(IResultTransformer resultTransformer);
/// <summary>
/// Returns the result of one of the Criteria based on the key
/// </summary>
/// <param name="key">The key</param>
/// <returns></returns>
object GetResult(string key);
}
// Since v5.2
[Obsolete("Use Multi.IQueryBatch instead, obtainable with ISession.CreateQueryBatch.")]
public static class MultiCriteriaExtensions
{
/// <summary>
/// Set a timeout for the underlying ADO.NET query.
/// </summary>
/// <param name="timeout">The timeout in seconds.</param>
/// <param name="multiCriteria">The <see cref="IMultiCriteria" /> on which to set the timeout.</param>
/// <returns><paramref name="multiCriteria" /> (for method chaining).</returns>
public static IMultiCriteria SetTimeout(this IMultiCriteria multiCriteria, int timeout)
{
if (multiCriteria == null)
{
throw new ArgumentNullException(nameof(multiCriteria));
}
if (multiCriteria is MultiCriteriaImpl impl)
{
return impl.SetTimeout(timeout);
}
throw new NotSupportedException(multiCriteria.GetType() + " does not support SetTimeout");
}
}
}