forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNhWithClause.cs
77 lines (69 loc) · 2.3 KB
/
NhWithClause.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
using System;
using System.Linq.Expressions;
using Remotion.Linq;
using Remotion.Linq.Clauses;
namespace NHibernate.Linq.Clauses
{
public class NhWithClause : NhClauseBase, IBodyClause
{
Expression _predicate;
/// <summary>
/// Initializes a new instance of the <see cref="T:NhWithClause" /> class.
/// </summary>
/// <param name="predicate">The predicate used to filter data items.</param>
public NhWithClause(Expression predicate)
{
if (predicate == null) throw new ArgumentNullException(nameof(predicate));
_predicate = predicate;
}
/// <summary>
/// Gets the predicate, the expression representing the where condition by which the data items are filtered
/// </summary>
public Expression Predicate
{
get { return _predicate; }
set
{
if (value == null) throw new ArgumentNullException(nameof(value));
_predicate = value;
}
}
public override string ToString()
{
return "with " + Predicate;
}
protected override void Accept(INhQueryModelVisitor visitor, QueryModel queryModel, int index)
{
visitor.VisitNhWithClause(this, queryModel, index);
}
IBodyClause IBodyClause.Clone(CloneContext cloneContext)
{
return Clone(cloneContext);
}
/// <summary>Clones this clause.</summary>
/// <param name="cloneContext">
/// The clones of all query source clauses are registered with this
/// <see cref="T:Remotion.Linq.Clauses.CloneContext" />.
/// </param>
/// <returns></returns>
public NhWithClause Clone(CloneContext cloneContext)
{
if (cloneContext == null) throw new ArgumentNullException("cloneContext");
return new NhWithClause(Predicate);
}
/// <summary>
/// Transforms all the expressions in this clause and its child objects via the given
/// <paramref name="transformation" /> delegate.
/// </summary>
/// <param name="transformation">
/// The transformation object. This delegate is called for each <see cref="T:System.Linq.Expressions.Expression" />
/// within this
/// clause, and those expressions will be replaced with what the delegate returns.
/// </param>
public void TransformExpressions(Func<Expression, Expression> transformation)
{
if (transformation == null) throw new ArgumentNullException("transformation");
Predicate = transformation(Predicate);
}
}
}