forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimpleSubqueryExpression.cs
42 lines (37 loc) · 1.13 KB
/
SimpleSubqueryExpression.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
using System;
using System.Collections.Generic;
using System.Linq;
using NHibernate.Engine;
using NHibernate.SqlCommand;
namespace NHibernate.Criterion
{
/// <summary>
/// A comparison between a constant value and the the result of a subquery
/// </summary>
[Serializable]
public class SimpleSubqueryExpression : SubqueryExpression
{
private Object value;
internal SimpleSubqueryExpression(Object value, String op, String quantifier, DetachedCriteria dc)
: base(op, quantifier, dc)
{
this.value = value;
}
public override TypedValue[] GetTypedValues(ICriteria criteria, ICriteriaQuery criteriaQuery)
{
TypedValue[] superTv = base.GetTypedValues(criteria, criteriaQuery);
TypedValue[] result = new TypedValue[superTv.Length + 1];
superTv.CopyTo(result, 1);
result[0] = FirstTypedValue();
return result;
}
private TypedValue FirstTypedValue()
{
return new TypedValue(GetTypes()[0], value, EntityMode.Poco);
}
protected override SqlString ToLeftSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery)
{
return new SqlString(criteriaQuery.NewQueryParameter(FirstTypedValue()).First());
}
}
}