Beispiel #1
0
        ��������public object UniqueResult()
        ��������
        {
            ������������return AbstractQueryImpl.UniqueElement(List());

            ��������
        }
Beispiel #2
0
        private IEnumerable <ITranslator> GetTranslators(AbstractQueryImpl query, QueryParameters queryParameters)
        {
            // NOTE: updates queryParameters.NamedParameters as (desired) side effect
            var queryString = query.ExpandParameterLists(queryParameters.NamedParameters);

            var sqlQuery = query as ISQLQuery;

            if (sqlQuery != null)
            {
                yield return(new SqlTranslator(sqlQuery, session.Factory));

                yield break;
            }

            foreach (var queryTranslator in session.GetQueries(queryString, false))
            {
                yield return(new HqlTranslatorWrapper(queryTranslator));
            }
        }
Beispiel #3
0
 public object UniqueResult()
 {
     return(AbstractQueryImpl.UniqueElement(List()));
 }
 public async Task <object> UniqueResultAsync(CancellationToken cancellationToken = default(CancellationToken))
 {
     cancellationToken.ThrowIfCancellationRequested();
     return(AbstractQueryImpl.UniqueElement(await(ListAsync(cancellationToken)).ConfigureAwait(false)));
 }
Beispiel #5
0
        /// <summary>
        /// Fill all <see cref="IQuery"/> properties.
        /// </summary>
        /// <param name="q">The <see cref="IQuery"/>.</param>
        /// <remarks>
        /// Query properties are overriden/merged.
        /// </remarks>
        protected void SetQueryProperties(IQuery q)
        {
            q.SetMaxResults(selection.MaxRows)
            .SetFirstResult(selection.FirstRow)
            .SetCacheable(cacheable)
            .SetReadOnly(readOnly)
            .SetTimeout(selection.Timeout)
            .SetFlushMode(flushMode)
            .SetFetchSize(selection.FetchSize);
            if (!string.IsNullOrEmpty(comment))
            {
                q.SetComment(comment);
            }
            if (!string.IsNullOrEmpty(cacheRegion))
            {
                q.SetCacheRegion(cacheRegion);
            }
            if (resultTransformer != null)
            {
                q.SetResultTransformer(resultTransformer);
            }
            if (cacheMode.HasValue)
            {
                q.SetCacheMode(cacheMode.Value);
            }
            foreach (KeyValuePair <string, LockMode> mode in lockModes)
            {
                q.SetLockMode(mode.Key, mode.Value);
            }

            // Set AbstractQueryImpl property before set parameters
            AbstractQueryImpl aqi = q as AbstractQueryImpl;

            if (aqi != null)
            {
                aqi.SetIgnoreUknownNamedParameters(shouldIgnoredUnknownNamedParameters);
            }

            // Even if the probably that somebody use a mixed technique to set parameters
            // (from POCO using SetProperties and using named parameter setters) here is a possible
            // difference between IQuery and DetachedQuery behaviour.
            // In IQuery we don't know who override a param value; in DetachedQuery the direct use of
            // a named parameter setter override the param value set by SetProperties(POCO)
            foreach (object obj in optionalUntypeParams)
            {
                q.SetProperties(obj);
            }

            // Set untyped positional parameters
            foreach (KeyValuePair <int, object> pup in posUntypeParams)
            {
                q.SetParameter(pup.Key, pup.Value);
            }

            // Set untyped named parameters
            foreach (KeyValuePair <string, object> nup in namedUntypeParams)
            {
                q.SetParameter(nup.Key, nup.Value);
            }

            // Set untyped named parameters list
            foreach (KeyValuePair <string, ICollection> nulp in namedUntypeListParams)
            {
                q.SetParameterList(nulp.Key, nulp.Value);
            }

            // Set typed positional parameters
            foreach (KeyValuePair <int, TypedValue> pp in posParams)
            {
                q.SetParameter(pp.Key, pp.Value.Value, pp.Value.Type);
            }

            // Set typed named parameters
            foreach (KeyValuePair <string, TypedValue> np in namedParams)
            {
                q.SetParameter(np.Key, np.Value.Value, np.Value.Type);
            }

            // Set typed named parameters List
            foreach (KeyValuePair <string, TypedValue> nlp in namedListParams)
            {
                q.SetParameterList(nlp.Key, (ICollection)nlp.Value.Value, nlp.Value.Type);
            }
        }