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


C# Engine.QueryParameters类代码示例

本文整理汇总了C#中NHibernate.Engine.QueryParameters的典型用法代码示例。如果您正苦于以下问题:C# QueryParameters类的具体用法?C# QueryParameters怎么用?C# QueryParameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


QueryParameters类属于NHibernate.Engine命名空间,在下文中一共展示了QueryParameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SubselectOneToManyLoader

		public SubselectOneToManyLoader(IQueryableCollection persister, SqlString subquery, ICollection<EntityKey> entityKeys,
		                                QueryParameters queryParameters,
		                                ISessionFactoryImplementor factory, IDictionary<string, IFilter> enabledFilters)
			: base(persister, BatchSizeForSubselectFetching, factory, enabledFilters)
		{
			keys = new object[entityKeys.Count];
			int i = 0;
			foreach (EntityKey entityKey in entityKeys)
			{
				keys[i++] = entityKey.Identifier;
			}

			// NH Different behavior: to deal with positionslParameter+NamedParameter+ParameterOfFilters
			namedParameters = new Dictionary<string, TypedValue>(queryParameters.NamedParameters);
			parametersSpecifications = queryParameters.ProcessedSqlParameters.ToList();
			var processedRowSelection = queryParameters.ProcessedRowSelection;
			SqlString finalSubquery = subquery;
			if (queryParameters.ProcessedRowSelection != null && !SubselectClauseExtractor.HasOrderBy(queryParameters.ProcessedSql))
			{
				// when the original query has an "ORDER BY" we can't re-apply the pagination.
				// This is a simplification, we should actually check which is the "ORDER BY" clause because when the "ORDER BY" is just for the PK we can re-apply "ORDER BY" and pagination.
				finalSubquery = GetSubSelectWithLimits(subquery, parametersSpecifications, processedRowSelection, namedParameters);
			}
			InitializeFromWalker(persister, finalSubquery, BatchSizeForSubselectFetching, enabledFilters, factory);

			types = queryParameters.PositionalParameterTypes;
			values = queryParameters.PositionalParameterValues;
		}
开发者ID:Ruhollah,项目名称:nhibernate-core,代码行数:28,代码来源:SubselectOneToManyLoader.cs

示例2: SqlCommandImpl

		public SqlCommandImpl(SqlString query, ICollection<IParameterSpecification> specifications, QueryParameters queryParameters, ISessionFactoryImplementor factory)
		{
			this.query = query;
			this.specifications = specifications;
			this.queryParameters = queryParameters;
			this.factory = factory;
		}
开发者ID:JKeyser,项目名称:nhibernate-core,代码行数:7,代码来源:SqlCommandImpl.cs

示例3: ValidateFailureDifferentLengths

		public void ValidateFailureDifferentLengths()
		{
			QueryParameters qp = new QueryParameters(
				new IType[] { NHibernateUtil.String },
				new object[] { });

			qp.ValidateParameters();
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:8,代码来源:QueryParametersFixture.cs

示例4: ValidateOk

		public void ValidateOk()
		{
			QueryParameters qp = new QueryParameters(
				new IType[] {NHibernateUtil.String},
				new object[] {"string"});

			qp.ValidateParameters();
		}
开发者ID:tkellogg,项目名称:NHibernate3-withProxyHooks,代码行数:8,代码来源:QueryParametersFixture.cs

示例5: ValidateFailureDifferentLengths

		public void ValidateFailureDifferentLengths()
		{
			QueryParameters qp = new QueryParameters(
				new IType[] {NHibernateUtil.String},
				new object[] {});

			Assert.Throws<QueryException>(() => qp.ValidateParameters());
		}
开发者ID:tkellogg,项目名称:NHibernate3-withProxyHooks,代码行数:8,代码来源:QueryParametersFixture.cs

示例6: ResetEffectiveExpectedType

		public static void ResetEffectiveExpectedType(this IEnumerable<IParameterSpecification> parameterSpecs, QueryParameters queryParameters)
		{
			// TODO: remove this method when we can infer the type during the parse
			foreach (var parameterSpecification in parameterSpecs.OfType<IExplicitParameterSpecification>())
			{
				parameterSpecification.SetEffectiveType(queryParameters);
			}
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:8,代码来源:ParametersBackTrackExtensions.cs

示例7: 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

示例8: Bind

		public void Bind(IDbCommand command, IList<Parameter> multiSqlQueryParametersList, int singleSqlParametersOffset, IList<Parameter> sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session)
		{
			IType type = keyType;
			object value = queryParameters.PositionalParameterValues[queryParameterPosition];

			string backTrackId = GetIdsForBackTrack(session.Factory).First(); // just the first because IType suppose the oders in certain sequence
			int position = sqlQueryParametersList.GetEffectiveParameterLocations(backTrackId).Single(); // an HQL positional parameter can't appear more than once
			type.NullSafeSet(command, value, position + singleSqlParametersOffset, session);
		}
开发者ID:Ruhollah,项目名称:nhibernate-core,代码行数:9,代码来源:CollectionFilterKeyParameterSpecification.cs

示例9: BindLimitParametersLastIfNeccesary

		protected virtual int BindLimitParametersLastIfNeccesary(IDbCommand command, QueryParameters parameter, int colIndex)
		{
			RowSelection selection = parameter.RowSelection;
			if (Loader.Loader.UseLimit(selection, dialect) && !dialect.BindLimitParametersFirst)
			{
				return Loader.Loader.BindLimitParameters(command, colIndex, selection, session);
			}
			return 0;
		}
开发者ID:pontillo,项目名称:PowerNap,代码行数:9,代码来源:BasicResultSetsCommand.cs

示例10: Bind

		public override void Bind(IDbCommand command, IList<Parameter> multiSqlQueryParametersList, int singleSqlParametersOffset, IList<Parameter> sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session)
		{
			TypedValue typedValue = queryParameters.NamedParameters[name];
			string backTrackId = GetIdsForBackTrack(session.Factory).First(); // just the first because IType suppose the oders in certain sequence
			foreach (int position in sqlQueryParametersList.GetEffectiveParameterLocations(backTrackId))
			{
				ExpectedType.NullSafeSet(command, GetPagingValue(typedValue.Value, session.Factory.Dialect, queryParameters), position + singleSqlParametersOffset, session);
			}
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:9,代码来源:NamedParameterSpecification.cs

示例11: Bind

		public void Bind(IDbCommand command, IList<Parameter> multiSqlQueryParametersList, int singleSqlParametersOffset, IList<Parameter> sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session)
		{
			TypedValue typedValue = queryParameters.NamedParameters[name];
			string backTrackId = GetIdsForBackTrack(session.Factory).First();
			foreach (int position in sqlQueryParametersList.GetEffectiveParameterLocations(backTrackId))
			{
				ExpectedType.NullSafeSet(command, typedValue.Value, position + singleSqlParametersOffset, session);
			}
		}
开发者ID:Ruhollah,项目名称:nhibernate-core,代码行数:9,代码来源:CriteriaNamedParameterSpecification.cs

示例12: ToSqlString

		public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
		{
			InitializeInnerQueryAndParameters(criteriaQuery);

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

			ISessionFactoryImplementor factory = criteriaQuery.Factory;

			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);
			}

			// during CriteriaImpl.Clone we are doing a shallow copy of each criterion.
			// this is not a problem for common criterion but not for SubqueryExpression because here we are holding the state of inner CriteriaTraslator (ICriteriaQuery).
			// After execution (ToSqlString) we have to clean the internal state because the next execution may be performed in a different tree reusing the same istance of SubqueryExpression.
			innerQuery = null;

			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:Ruhollah,项目名称:nhibernate-core,代码行数:56,代码来源:SubqueryExpression.cs

示例13: Bind

		public int Bind(
			IDbCommand statement,
			QueryParameters qp,
			ISessionImplementor session,
			int position)
		{
			object value = qp.PositionalParameterValues[_queryParameterPosition];
			_keyType.NullSafeSet(statement, value, position, session);
			return _keyType.GetColumnSpan(session.Factory);
		}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:10,代码来源:CollectionFilterKeyParameterSpecification.cs

示例14: Bind

		public int Bind(IDbCommand statement, QueryParameters qp, ISessionImplementor session, int position)
		{
			int bindCount = 0;

			foreach (IParameterSpecification spec in _paramSpecs)
			{
				bindCount += spec.Bind(statement, qp, session, position + bindCount);
			}
			return bindCount;
		}
开发者ID:Mrding,项目名称:Ribbon,代码行数:10,代码来源:AggregatedIndexCollectionSelectorParameterSpecifications.cs

示例15: SubselectFetch

		public SubselectFetch(string alias, ILoadable loadable, QueryParameters queryParameters,
		                      ISet<EntityKey> resultingEntityKeys)
		{
			this.resultingEntityKeys = resultingEntityKeys;
			this.queryParameters = queryParameters;
			this.loadable = loadable;
			this.alias = alias;

			queryString = queryParameters.ProcessedSql.GetSubselectString();
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:10,代码来源:SubselectFetch.cs


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