當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。