/src/NHibernate.Spatial/src/NHibernate.Spatial/Linq/Functions/SpatialPropertyGenerator.cs
C# | 36 lines | 33 code | 3 blank | 0 comment | 2 complexity | 662c1954ca4e26cea173146a966e6691 MD5 | raw file
Possible License(s): BSD-3-Clause, MPL-2.0-no-copyleft-exception, CC-BY-SA-3.0, GPL-2.0, Apache-2.0, LGPL-3.0, LGPL-2.1
- using System;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Reflection;
- using GeoAPI.Geometries;
- using NHibernate.Hql.Ast;
- using NHibernate.Linq;
- using NHibernate.Linq.Functions;
- using NHibernate.Linq.Visitors;
- using NHibernate.Spatial.Dialect;
-
- namespace NHibernate.Spatial.Linq.Functions
- {
- public abstract class SpatialPropertyGenerator<TGeometry, TResult> : BaseHqlGeneratorForProperty
- where TGeometry : IGeometry
- {
- protected SpatialPropertyGenerator(params Expression<Func<TGeometry, TResult>>[] expressions)
- {
- SupportedProperties = expressions.Select(o => ReflectionHelper.GetProperty(o)).ToArray();
- }
-
- public override HqlTreeNode BuildHql(MemberInfo member, Expression expression, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
- {
- var methodCall = treeBuilder.MethodCall(SpatialDialect.HqlPrefix + member.Name, new[]
- {
- visitor.Visit(expression).AsExpression()
- });
- if (typeof(TResult) == typeof(bool))
- {
- return treeBuilder.Equality(methodCall, treeBuilder.True());
- }
- return methodCall;
- }
- }
-
- }