forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAggregateProjection.cs
45 lines (40 loc) · 1.19 KB
/
AggregateProjection.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
using System;
using NHibernate.SqlCommand;
using NHibernate.Type;
namespace NHibernate.Expression
{
/// <summary>
/// An Aggregation
/// </summary>
[Serializable]
public class AggregateProjection : SimpleProjection
{
protected readonly string propertyName;
protected readonly string aggregate;
protected internal AggregateProjection(string aggregate, string propertyName)
{
this.aggregate = aggregate;
this.propertyName = propertyName;
}
public override string ToString()
{
return aggregate + "(" + propertyName + ')';
}
public override IType[] GetTypes(ICriteria criteria, ICriteriaQuery criteriaQuery)
{
return new IType[] {criteriaQuery.GetType(criteria, propertyName)};
}
public override SqlString ToSqlString(ICriteria criteria, int loc, ICriteriaQuery criteriaQuery)
{
return new SqlString(new object[]
{
aggregate,
"(",
criteriaQuery.GetColumn(criteria, propertyName),
") as y",
loc.ToString(),
"_"
});
}
}
}