forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNotExpression.cs
72 lines (63 loc) · 1.85 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System.Collections;
using NHibernate.Engine;
using NHibernate.SqlCommand;
namespace NHibernate.Expression
{
/// <summary>
/// An <see cref="ICriterion"/> that negates another <see cref="ICriterion"/>.
/// </summary>
public class NotExpression : AbstractCriterion
{
private 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;
}
/// <summary>
///
/// </summary>
/// <param name="factory"></param>
/// <param name="persistentClass"></param>
/// <param name="alias"></param>
/// <returns></returns>
public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias, IDictionary aliasClasses )
{
//TODO: set default capacity
SqlStringBuilder builder = new SqlStringBuilder();
if( factory.Dialect is Dialect.MySQLDialect )
{
builder.Add( "not (" );
}
else
{
builder.Add( "not " );
}
builder.Add( _criterion.ToSqlString( factory, persistentClass, alias, aliasClasses ) );
if( factory.Dialect is Dialect.MySQLDialect )
{
builder.Add( ")" );
}
return builder.ToSqlString();
}
/// <summary>
///
/// </summary>
/// <param name="sessionFactory"></param>
/// <param name="persistentClass"></param>
/// <returns></returns>
public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, IDictionary aliasClasses )
{
return _criterion.GetTypedValues( sessionFactory, persistentClass, aliasClasses );
}
/// <summary></summary>
public override string ToString()
{
return "not " + _criterion.ToString();
}
}
}