forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNotExpression.cs
51 lines (44 loc) · 1.29 KB
/
NotExpression.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
using System;
using NHibernate.Engine;
using NHibernate.SqlCommand;
namespace NHibernate.Criterion
{
/// <summary>
/// An <see cref="ICriterion"/> that negates another <see cref="ICriterion"/>.
/// </summary>
[Serializable]
public class NotExpression : AbstractCriterion
{
private readonly ICriterion _criterion;
/// <summary>
/// Initialize a new instance of the <see cref="NotExpression" /> class for an
/// <see cref="ICriterion"/>
/// </summary>
/// <param name="criterion">The <see cref="ICriterion"/> to negate.</param>
public NotExpression(ICriterion criterion)
{
_criterion = criterion;
}
public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery)
{
//TODO: set default capacity
var builder = new SqlStringBuilder();
builder.Add("not (");
builder.Add(_criterion.ToSqlString(criteria, criteriaQuery));
builder.Add(")");
return builder.ToSqlString();
}
public override TypedValue[] GetTypedValues(ICriteria criteria, ICriteriaQuery criteriaQuery)
{
return _criterion.GetTypedValues(criteria, criteriaQuery);
}
public override string ToString()
{
return string.Format("not ({0})", _criterion.ToString());
}
public override IProjection[] GetProjections()
{
return _criterion.GetProjections();
}
}
}