当前位置: 首页>>代码示例>>C#>>正文


C# ICriteriaQuery.GenerateSQLAlias方法代码示例

本文整理汇总了C#中ICriteriaQuery.GenerateSQLAlias方法的典型用法代码示例。如果您正苦于以下问题:C# ICriteriaQuery.GenerateSQLAlias方法的具体用法?C# ICriteriaQuery.GenerateSQLAlias怎么用?C# ICriteriaQuery.GenerateSQLAlias使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICriteriaQuery的用法示例。


在下文中一共展示了ICriteriaQuery.GenerateSQLAlias方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToSqlString

		public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
		{
			ISessionFactoryImplementor factory = criteriaQuery.Factory;

			var innerQuery = new CriteriaQueryTranslator(
				factory,
				criteriaImpl, //implicit polymorphism not supported (would need a union)
				criteriaImpl.EntityOrClassName,
				criteriaQuery.GenerateSQLAlias(),
				criteriaQuery);

			types = innerQuery.HasProjection ? innerQuery.ProjectedTypes : null;

			if (innerQuery.HasProjection == false)
			{
				throw new QueryException("Cannot use subqueries on a criteria without a projection.");
			}

			IOuterJoinLoadable persister = (IOuterJoinLoadable) factory.GetEntityPersister(criteriaImpl.EntityOrClassName);

			//patch to generate joins on subqueries
			//stolen from CriteriaLoader
			CriteriaJoinWalker walker =
				new CriteriaJoinWalker(persister, innerQuery, factory, criteriaImpl, criteriaImpl.EntityOrClassName, enabledFilters);

			parameters = innerQuery.GetQueryParameters(); // parameters can be inferred only after initialize the walker

			SqlString sql = walker.SqlString;

			if (criteriaImpl.FirstResult != 0 || criteriaImpl.MaxResults != RowSelection.NoValue)
			{
				int? offset = Loader.Loader.GetOffsetUsingDialect(parameters.RowSelection, factory.Dialect);
				int? limit = Loader.Loader.GetLimitUsingDialect(parameters.RowSelection, factory.Dialect);
				Parameter offsetParameter = offset.HasValue ? innerQuery.CreateSkipParameter(offset.Value) : null;
				Parameter limitParameter = limit.HasValue ? innerQuery.CreateTakeParameter(limit.Value) : null;
				sql = factory.Dialect.GetLimitString(sql, offset, limit, offsetParameter, limitParameter);
			}

			SqlStringBuilder buf = new SqlStringBuilder().Add(ToLeftSqlString(criteria, criteriaQuery));
			if (op != null)
			{
				buf.Add(" ").Add(op).Add(" ");
			}

			if (quantifier != null && prefixOp)
			{
				buf.Add(quantifier).Add(" ");
			}

			buf.Add("(").Add(sql).Add(")");

			if (quantifier != null && prefixOp == false)
			{
				buf.Add(" ").Add(quantifier);
			}

			return buf.ToSqlString();
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:58,代码来源:SubqueryExpression.cs

示例2: InitializeInnerQueryAndParameters

		public void InitializeInnerQueryAndParameters(ICriteriaQuery criteriaQuery)
		{
			if (innerQuery == null)
			{
				ISessionFactoryImplementor factory = criteriaQuery.Factory;

				innerQuery = new CriteriaQueryTranslator(
					factory,
					criteriaImpl, //implicit polymorphism not supported (would need a union)
					criteriaImpl.EntityOrClassName,
					criteriaQuery.GenerateSQLAlias(),
					criteriaQuery);

				types = innerQuery.HasProjection ? innerQuery.ProjectedTypes : null;
			}
		}
开发者ID:Ruhollah,项目名称:nhibernate-core,代码行数:16,代码来源:SubqueryExpression.cs

示例3: InitializeInnerQueryAndParameters

		// NH: This feels like a hack but I don't understand the code enough yet to code a better solution
		private void InitializeInnerQueryAndParameters(ICriteriaQuery criteriaQuery)
		{
			if (innerQuery != null)
			{
				// Already initialized
				return;
			}

			ISessionFactoryImplementor factory = criteriaQuery.Factory;
			innerQuery = new CriteriaQueryTranslator(factory,
			                                         this.criteriaImpl,
			                                         //implicit polymorphism not supported (would need a union) 
			                                         this.criteriaImpl.CriteriaClass,
			                                         criteriaQuery.GenerateSQLAlias(),
			                                         criteriaQuery);

			parameters = innerQuery.GetQueryParameters();
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:19,代码来源:SubqueryExpression.cs


注:本文中的ICriteriaQuery.GenerateSQLAlias方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。