コード例 #1
0
        public async Task BindAsync(DbCommand command, IList <Parameter> sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            int position = sqlQueryParametersList.GetEffectiveParameterLocations(IdBackTrack).Single();             // version parameter can't appear more than once

            await(type.NullSafeSetAsync(command, await(type.SeedAsync(session, cancellationToken)).ConfigureAwait(false), position, session, cancellationToken)).ConfigureAwait(false);
        }
		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);
		}
コード例 #3
0
		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);
			}
		}
コード例 #4
0
		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);
			}
		}
コード例 #5
0
        public void Bind(DbCommand 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);
        }
コード例 #6
0
        public override void Bind(DbCommand 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);
            }
        }
コード例 #7
0
        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);
            }
        }
コード例 #8
0
        public override async Task BindAsync(DbCommand command, IList <Parameter> multiSqlQueryParametersList, int singleSqlParametersOffset, IList <Parameter> sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            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))
            {
                await(ExpectedType.NullSafeSetAsync(command, GetPagingValue(typedValue.Value, session.Factory.Dialect, queryParameters), position + singleSqlParametersOffset, session, cancellationToken)).ConfigureAwait(false);
            }
        }
        public async Task BindAsync(DbCommand command, IList <Parameter> multiSqlQueryParametersList, int singleSqlParametersOffset, IList <Parameter> sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            TypedValue typedValue  = queryParameters.NamedParameters[name];
            string     backTrackId = GetIdsForBackTrack(session.Factory).First();

            foreach (int position in sqlQueryParametersList.GetEffectiveParameterLocations(backTrackId))
            {
                await(ExpectedType.NullSafeSetAsync(command, typedValue.Value, position + singleSqlParametersOffset, session, cancellationToken)).ConfigureAwait(false);
            }
        }
		public void Bind(IDbCommand command, IList<Parameter> multiSqlQueryParametersList, int singleSqlParametersOffset, IList<Parameter> sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session)
		{
			string backTrackId = GetIdsForBackTrack(session.Factory).First(); // just the first because IType suppose the oders in certain sequence

			// The same filterName-parameterName can appear more than once in the whole query
			object value = session.GetFilterParameterValue(filterParameterFullName);
			foreach (int position in multiSqlQueryParametersList.GetEffectiveParameterLocations(backTrackId))
			{
				ExpectedType.NullSafeSet(command, value, position, session);
			}
		}
コード例 #11
0
		public override void Bind(IDbCommand command, IList<Parameter> multiSqlQueryParametersList, int singleSqlParametersOffset, IList<Parameter> sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session)
		{
			IType type = ExpectedType;
			object value = queryParameters.PositionalParameterValues[hqlPosition];

			string backTrackId = GetIdsForBackTrack(session.Factory).First(); // just the first because IType suppose the oders in certain sequence
			// an HQL positional parameter can appear more than once because a custom HQL-Function can duplicate it
			foreach (int position in sqlQueryParametersList.GetEffectiveParameterLocations(backTrackId))
			{
				type.NullSafeSet(command, GetPagingValue(value, session.Factory.Dialect, queryParameters), position + singleSqlParametersOffset, session);
			}
		}
コード例 #12
0
		public void Bind(IDbCommand command, IList<Parameter> multiSqlQueryParametersList, int singleSqlParametersOffset, IList<Parameter> sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session)
		{
			// The QueryTakeParameterSpecification is unique so we can use multiSqlQueryParametersList
			var effectiveParameterLocations = multiSqlQueryParametersList.GetEffectiveParameterLocations(limitParametersNameForThisQuery).ToArray();
			if (effectiveParameterLocations.Any())
			{
				// if the dialect does not support variable limits the parameter may was removed
				int value = queryParameters.RowSelection.MaxRows;
				int position = effectiveParameterLocations.Single();
				type.NullSafeSet(command, value, position, session);
			}
		}
コード例 #13
0
		public void Bind(IDbCommand command, IList<Parameter> multiSqlQueryParametersList, int singleSqlParametersOffset, IList<Parameter> sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session)
		{
			// The QuerySkipParameterSpecification is unique so we can use multiSqlQueryParametersList
			var effectiveParameterLocations = multiSqlQueryParametersList.GetEffectiveParameterLocations(limitParametersNameForThisQuery).ToArray();
			if (effectiveParameterLocations.Length > 0)
			{
				// if the dialect does not support variable limits the parameter may was removed
				int value = Loader.Loader.GetOffsetUsingDialect(queryParameters.RowSelection, session.Factory.Dialect) ?? queryParameters.RowSelection.FirstRow;
				int position = effectiveParameterLocations[0];
				type.NullSafeSet(command, value, position, session);
			}
		}
        public void Bind(IDbCommand command, IList <Parameter> multiSqlQueryParametersList, int singleSqlParametersOffset, IList <Parameter> sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session)
        {
            string backTrackId = GetIdsForBackTrack(session.Factory).First();             // just the first because IType suppose the oders in certain sequence

            // The same filterName-parameterName can appear more than once in the whole query
            object value = session.GetFilterParameterValue(filterParameterFullName);

            foreach (int position in multiSqlQueryParametersList.GetEffectiveParameterLocations(backTrackId))
            {
                ExpectedType.NullSafeSet(command, value, position, session);
            }
        }
コード例 #15
0
        public void Bind(IDbCommand command, IList <Parameter> multiSqlQueryParametersList, int singleSqlParametersOffset, IList <Parameter> sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session)
        {
            // The QueryTakeParameterSpecification is unique so we can use multiSqlQueryParametersList
            var effectiveParameterLocations = multiSqlQueryParametersList.GetEffectiveParameterLocations(limitParametersNameForThisQuery).ToArray();

            if (effectiveParameterLocations.Any())
            {
                // if the dialect does not support variable limits the parameter may was removed
                int value    = Loader.Loader.GetLimitUsingDialect(queryParameters.RowSelection, session.Factory.Dialect) ?? queryParameters.RowSelection.MaxRows;
                int position = effectiveParameterLocations.Single();
                type.NullSafeSet(command, value, position, session);
            }
        }
コード例 #16
0
        public void Bind(IDbCommand command, IList <Parameter> multiSqlQueryParametersList, int singleSqlParametersOffset, IList <Parameter> sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session)
        {
            // The QuerySkipParameterSpecification is unique so we can use multiSqlQueryParametersList
            var effectiveParameterLocations = multiSqlQueryParametersList.GetEffectiveParameterLocations(limitParametersNameForThisQuery).ToArray();

            if (effectiveParameterLocations.Length > 0)
            {
                // if the dialect does not support variable limits the parameter may was removed
                int value    = queryParameters.RowSelection.FirstRow;
                int position = effectiveParameterLocations[0];
                type.NullSafeSet(command, value, position, session);
            }
        }
コード例 #17
0
        public async Task BindAsync(DbCommand command, IList <Parameter> multiSqlQueryParametersList, int singleSqlParametersOffset, IList <Parameter> sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            string backTrackId = GetIdsForBackTrack(session.Factory).First();             // just the first because IType suppose the oders in certain sequence

            // The same filterName-parameterName can appear more than once in the whole query
            object value = session.GetFilterParameterValue(filterParameterFullName);

            foreach (int position in multiSqlQueryParametersList.GetEffectiveParameterLocations(backTrackId))
            {
                await(ExpectedType.NullSafeSetAsync(command, value, position, session, cancellationToken)).ConfigureAwait(false);
            }
        }
コード例 #18
0
        public override void Bind(DbCommand command, IList <Parameter> multiSqlQueryParametersList, int singleSqlParametersOffset, IList <Parameter> sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session)
        {
            IType  type  = ExpectedType;
            object value = queryParameters.PositionalParameterValues[hqlPosition];

            string backTrackId = GetIdsForBackTrack(session.Factory).First();             // just the first because IType suppose the oders in certain sequence

            // an HQL positional parameter can appear more than once because a custom HQL-Function can duplicate it
            foreach (int position in sqlQueryParametersList.GetEffectiveParameterLocations(backTrackId))
            {
                type.NullSafeSet(command, GetPagingValue(value, session.Factory.Dialect, queryParameters), position + singleSqlParametersOffset, session);
            }
        }
コード例 #19
0
        public override async Task BindAsync(DbCommand command, IList <Parameter> multiSqlQueryParametersList, int singleSqlParametersOffset, IList <Parameter> sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            IType  type  = ExpectedType;
            object value = queryParameters.PositionalParameterValues[hqlPosition];

            string backTrackId = GetIdsForBackTrack(session.Factory).First();             // just the first because IType suppose the oders in certain sequence

            // an HQL positional parameter can appear more than once because a custom HQL-Function can duplicate it
            foreach (int position in sqlQueryParametersList.GetEffectiveParameterLocations(backTrackId))
            {
                await(type.NullSafeSetAsync(command, GetPagingValue(value, session.Factory.Dialect, queryParameters), position + singleSqlParametersOffset, session, cancellationToken)).ConfigureAwait(false);
            }
        }
コード例 #20
0
		public static SqlType[] GetQueryParameterTypes(this IEnumerable<IParameterSpecification> parameterSpecs, IList<Parameter> sqlQueryParametersList, ISessionFactoryImplementor factory)
		{
			// NOTE: if you have a NullReferenceException probably is because the IParameterSpecification does not have the ExpectedType; use ResetEffectiveExpectedType before call this method.
			
			// due to IType.NullSafeSet(System.Data.IDbCommand , object, int, ISessionImplementor) the SqlType[] is supposed to be in a certain sequence.
			// here we can check and evetually Assert (see AssertionFailure) the supposition because each individual Parameter has its BackTrackId.
			// Currently we just take the first BackTrackId of each IParameterSpecification
			IEnumerable<IType> typesSequence = from typeLocation in
			                                   	from specification in parameterSpecs
			                                   	let firstParameterId = specification.GetIdsForBackTrack(factory).First()
			                                   	let effectiveParameterLocations = sqlQueryParametersList.GetEffectiveParameterLocations(firstParameterId)
			                                   	from location in effectiveParameterLocations
			                                   	select new {Location = location, Type = specification.ExpectedType}
			                                   group typeLocation by typeLocation.Location
			                                   into locations
			                                   orderby locations.Key
			                                   select locations.First().Type;
			return typesSequence.SelectMany(t => t.SqlTypes(factory)).ToArray();
		}
コード例 #21
0
        public Task BindAsync(DbCommand command, IList <Parameter> multiSqlQueryParametersList, int singleSqlParametersOffset, IList <Parameter> sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session, CancellationToken cancellationToken)
        {
            if (cancellationToken.IsCancellationRequested)
            {
                return(Task.FromCanceled <object>(cancellationToken));
            }
            try
            {
                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
                return(type.NullSafeSetAsync(command, value, position + singleSqlParametersOffset, session, cancellationToken));
            }
            catch (Exception ex)
            {
                return(Task.FromException <object>(ex));
            }
        }
コード例 #22
0
 public Task BindAsync(DbCommand command, IList <Parameter> multiSqlQueryParametersList, int singleSqlParametersOffset, IList <Parameter> sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session, CancellationToken cancellationToken)
 {
     if (cancellationToken.IsCancellationRequested)
     {
         return(Task.FromCanceled <object>(cancellationToken));
     }
     try
     {
         // The QuerySkipParameterSpecification is unique so we can use multiSqlQueryParametersList
         var effectiveParameterLocations = multiSqlQueryParametersList.GetEffectiveParameterLocations(limitParametersNameForThisQuery).ToArray();
         if (effectiveParameterLocations.Length > 0)
         {
             // if the dialect does not support variable limits the parameter may was removed
             int value    = Loader.Loader.GetOffsetUsingDialect(queryParameters.RowSelection, session.Factory.Dialect) ?? queryParameters.RowSelection.FirstRow;
             int position = effectiveParameterLocations[0];
             return(type.NullSafeSetAsync(command, value, position, session, cancellationToken));
         }
         return(Task.CompletedTask);
     }
     catch (Exception ex)
     {
         return(Task.FromException <object>(ex));
     }
 }
コード例 #23
0
		public void Bind(IDbCommand command, IList<Parameter> sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session)
		{
			int position = sqlQueryParametersList.GetEffectiveParameterLocations(IdBackTrack).Single(); // version parameter can't appear more than once
			type.NullSafeSet(command, type.Seed(session), position, session);
		}
コード例 #24
0
        public void Bind(DbCommand command, IList <Parameter> sqlQueryParametersList, QueryParameters queryParameters, ISessionImplementor session)
        {
            int position = sqlQueryParametersList.GetEffectiveParameterLocations(IdBackTrack).Single();             // version parameter can't appear more than once

            type.NullSafeSet(command, type.Seed(session), position, session);
        }
コード例 #25
0
        public static SqlType[] GetQueryParameterTypes(this IEnumerable <IParameterSpecification> parameterSpecs, IList <Parameter> sqlQueryParametersList, ISessionFactoryImplementor factory)
        {
            // NOTE: if you have a NullReferenceException probably is because the IParameterSpecification does not have the ExpectedType; use ResetEffectiveExpectedType before call this method.

            // due to IType.NullSafeSet(DbCommand , object, int, ISessionImplementor) the SqlType[] is supposed to be in a certain sequence.
            // here we can check and evetually Assert (see AssertionFailure) the supposition because each individual Parameter has its BackTrackId.
            // Currently we just take the first BackTrackId of each IParameterSpecification
            IEnumerable <IType> typesSequence = from typeLocation in
                                                from specification in parameterSpecs
                                                let firstParameterId = specification.GetIdsForBackTrack(factory).First()
                                                                       let effectiveParameterLocations = sqlQueryParametersList.GetEffectiveParameterLocations(firstParameterId)
                                                                                                         from location in effectiveParameterLocations
                                                                                                         select new { Location = location, Type = specification.ExpectedType }
            group typeLocation by typeLocation.Location
            into locations
            orderby locations.Key
            select locations.First().Type;

            return(typesSequence.SelectMany(t => t.SqlTypes(factory)).ToArray());
        }