1- using Remotion . Linq . Clauses ;
2- using Remotion . Linq . Clauses . ExpressionTreeVisitors ;
1+ using System ;
32using System . Linq . Expressions ;
3+ using Remotion . Linq ;
4+ using Remotion . Linq . Clauses ;
45
56namespace NHibernate . Linq . Clauses
67{
7- public class NhHavingClause : WhereClause
8+ public class NhHavingClause : IBodyClause
89 {
9- public NhHavingClause ( Expression predicate )
10- : base ( predicate )
10+ Expression _predicate ;
11+
12+ /// <summary>
13+ /// Initializes a new instance of the <see cref="T:Remotion.Linq.Clauses.WhereClause" /> class.
14+ /// </summary>
15+ /// <param name="predicate">The predicate used to filter data items.</param>
16+ public NhHavingClause ( Expression predicate )
17+ {
18+ if ( predicate == null ) throw new ArgumentNullException ( nameof ( predicate ) ) ;
19+ _predicate = predicate ;
20+ }
21+
22+ /// <summary>
23+ /// Gets the predicate, the expression representing the where condition by which the data items are filtered
24+ /// </summary>
25+ public Expression Predicate
26+ {
27+ get { return _predicate ; }
28+ set
29+ {
30+ if ( value == null ) throw new ArgumentNullException ( nameof ( value ) ) ;
31+ _predicate = value ;
32+ }
33+ }
34+
35+ /// <summary>
36+ /// Accepts the specified visitor by calling its
37+ /// <see
38+ /// cref="M:Remotion.Linq.IQueryModelVisitor.VisitWhereClause(Remotion.Linq.Clauses.WhereClause,Remotion.Linq.QueryModel,System.Int32)" />
39+ /// method.
40+ /// </summary>
41+ /// <param name="visitor">The visitor to accept.</param>
42+ /// <param name="queryModel">The query model in whose context this clause is visited.</param>
43+ /// <param name="index">
44+ /// The index of this clause in the <paramref name="queryModel" />'s
45+ /// <see cref="P:Remotion.Linq.QueryModel.BodyClauses" /> collection.
46+ /// </param>
47+ public void Accept ( IQueryModelVisitor visitor , QueryModel queryModel , int index )
1148 {
49+ if ( visitor == null ) throw new ArgumentNullException ( nameof ( visitor ) ) ;
50+ if ( queryModel == null ) throw new ArgumentNullException ( nameof ( queryModel ) ) ;
51+ ( ( INhQueryModelVisitor ) visitor ) . VisitNhHavingClause ( this , queryModel , index ) ;
52+ }
53+
54+ IBodyClause IBodyClause . Clone ( CloneContext cloneContext )
55+ {
56+ return Clone ( cloneContext ) ;
57+ }
58+
59+ /// <summary>
60+ /// Transforms all the expressions in this clause and its child objects via the given
61+ /// <paramref name="transformation" /> delegate.
62+ /// </summary>
63+ /// <param name="transformation">
64+ /// The transformation object. This delegate is called for each <see cref="T:System.Linq.Expressions.Expression" />
65+ /// within this
66+ /// clause, and those expressions will be replaced with what the delegate returns.
67+ /// </param>
68+ public void TransformExpressions ( Func < Expression , Expression > transformation )
69+ {
70+ if ( transformation == null ) throw new ArgumentNullException ( nameof ( transformation ) ) ;
71+ Predicate = transformation ( Predicate ) ;
1272 }
1373
1474 public override string ToString ( )
1575 {
16- return "having " + FormattingExpressionTreeVisitor . Format ( Predicate ) ;
76+ return "having " + Predicate ;
77+ }
78+
79+ /// <summary>Clones this clause.</summary>
80+ /// <param name="cloneContext">
81+ /// The clones of all query source clauses are registered with this
82+ /// <see cref="T:Remotion.Linq.Clauses.CloneContext" />.
83+ /// </param>
84+ /// <returns></returns>
85+ public NhHavingClause Clone ( CloneContext cloneContext )
86+ {
87+ if ( cloneContext == null ) throw new ArgumentNullException ( nameof ( cloneContext ) ) ;
88+ return new NhHavingClause ( Predicate ) ;
1789 }
1890 }
19- }
91+ }
0 commit comments