///<summary> /// ///</summary> ///<param name="method"></param> ///<param name="targetObject">Should be an ISecurable</param> ///<param name="arguments">Not sure what the heck arg[0] is, but arg[1] is the entityName</param> ///<param name="treeBuilder"></param> ///<param name="visitor"></param> ///<returns></returns> public override HqlTreeNode BuildHql( MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor) { // arguments[0] is a System.Linq.Expressions.Expression // arguments[1] is our constant value var expr = arguments[0]; // This doesn't really help us right now, but log it just in case... if (expr is Remotion.Linq.Clauses.Expressions.QuerySourceReferenceExpression) { Console.WriteLine( "ReferencedQuerySource: {0}", ((Remotion.Linq.Clauses.Expressions.QuerySourceReferenceExpression)expr).ReferencedQuerySource ); } // Getting somewhere? // expr.Type is Spc.Ofp.Tubs.DAL.Entities.Trip Console.WriteLine("Expression type: {0}", expr.Type); // HqlAlias is "AccessControl" (entity property), "ace" (name used in expression) ? // HqlExpression is equality expression ? var aceAlias = treeBuilder.Alias("AccessControl as ace"); var entityName = ((ConstantExpression)arguments[1]).Value; Console.WriteLine("entityName: {0}", entityName); var equality = treeBuilder.Equality( treeBuilder.Alias("ace.EntityName"), treeBuilder.Constant(entityName) ); var joinExpression = treeBuilder.Join(equality, aceAlias); // This doesn't actually do anything... return visitor.Visit(expr).AsExpression(); /* * var dc = DetachedCriteria.For<T>() .CreateAlias("AccessControl", "ace", JoinType.InnerJoin) .Add(NHibernate.Criterion.Expression.Eq("ace.EntityName", this._entityName)); */ }