當前位置: 首頁>>代碼示例>>C#>>正文


C# HqlTreeBuilder.Alias方法代碼示例

本文整理匯總了C#中NHibernate.Hql.Ast.HqlTreeBuilder.Alias方法的典型用法代碼示例。如果您正苦於以下問題:C# HqlTreeBuilder.Alias方法的具體用法?C# HqlTreeBuilder.Alias怎麽用?C# HqlTreeBuilder.Alias使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NHibernate.Hql.Ast.HqlTreeBuilder的用法示例。


在下文中一共展示了HqlTreeBuilder.Alias方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: BuildHql

        ///<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));
             */
        }
開發者ID:spc-ofp,項目名稱:tubs-data-clr,代碼行數:58,代碼來源:AclContainsGenerator.cs

示例2: BuildHql

		public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
		{
			// All has two arguments.  Arg 1 is the source and arg 2 is the predicate
			var predicate = (LambdaExpression) arguments[1];

			return treeBuilder.BooleanNot(
				treeBuilder.Exists(
					treeBuilder.Query(
						treeBuilder.SelectFrom(
							treeBuilder.From(
								treeBuilder.Range(
									visitor.Visit(arguments[0]),
									treeBuilder.Alias(predicate.Parameters[0].Name))
								)
							),
						treeBuilder.Where(
							treeBuilder.BooleanNot(visitor.Visit(arguments[1]).AsBooleanExpression())
							)
						)
					)
				);
		}
開發者ID:jlevitt,項目名稱:nhibernate-core,代碼行數:22,代碼來源:QueryableGenerator.cs


注:本文中的NHibernate.Hql.Ast.HqlTreeBuilder.Alias方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。