Esempio n. 1
0
        internal IEnumerable GetEnumerable(QueryParameters queryParameters, ISessionImplementor session)
        {
            CheckQuery(queryParameters);
            bool statsEnabled = session.Factory.Statistics.IsStatisticsEnabled;

            var stopWath = new Stopwatch();

            if (statsEnabled)
            {
                stopWath.Start();
            }

            IDbCommand cmd = PrepareQueryCommand(queryParameters, false, session);

            // This IDataReader is disposed of in EnumerableImpl.Dispose
            IDataReader rs = GetResultSet(cmd, queryParameters.HasAutoDiscoverScalarTypes, false, queryParameters.RowSelection,
                                          session);

            HolderInstantiator hi = HolderInstantiator.GetHolderInstantiator(_selectNewTransformer,
                                                                             queryParameters.ResultTransformer,
                                                                             _queryReturnAliases);

            IEnumerable result = new EnumerableImpl(rs, cmd, session, _queryTranslator.ReturnTypes,
                                                    _queryTranslator.GetColumnNames(), queryParameters.RowSelection, hi);

            if (statsEnabled)
            {
                stopWath.Stop();
                session.Factory.StatisticsImplementor.QueryExecuted("HQL: " + _queryTranslator.QueryString, 0, stopWath.Elapsed);
                // NH: Different behavior (H3.2 use QueryLoader in AST parser) we need statistic for orginal query too.
                // probably we have a bug some where else for statistic RowCount
                session.Factory.StatisticsImplementor.QueryExecuted(QueryIdentifier, 0, stopWath.Elapsed);
            }
            return(result);
        }
Esempio n. 2
0
        internal IEnumerable GetEnumerable(QueryParameters queryParameters, IEventSource session)
        {
            CheckQuery(queryParameters);
            Stopwatch stopWatch = null;

            if (session.Factory.Statistics.IsStatisticsEnabled)
            {
                stopWatch = Stopwatch.StartNew();
            }

            var cmd = PrepareQueryCommand(queryParameters, false, session);

            // This DbDataReader is disposed of in EnumerableImpl.Dispose
            var rs = GetResultSet(cmd, queryParameters, session, null);

            var         resultTransformer = _selectNewTransformer ?? queryParameters.ResultTransformer;
            IEnumerable result            =
                new EnumerableImpl(rs, cmd, session, queryParameters.IsReadOnly(session), _queryTranslator.ReturnTypes, _queryTranslator.GetColumnNames(), queryParameters.RowSelection, resultTransformer, _queryReturnAliases);

            if (stopWatch != null)
            {
                stopWatch.Stop();
                session.Factory.StatisticsImplementor.QueryExecuted("HQL: " + _queryTranslator.QueryString, 0, stopWatch.Elapsed);
                // NH: Different behavior (H3.2 use QueryLoader in AST parser) we need statistic for orginal query too.
                // probably we have a bug some where else for statistic RowCount
                session.Factory.StatisticsImplementor.QueryExecuted(QueryIdentifier, 0, stopWatch.Elapsed);
            }
            return(result);
        }