protected bool IsUseFetchNarrowingResultSetWrapper()
        {
            FetchNarrowingBean fnbean = FetchNarrowingBeanContext.GetFetchNarrowingBeanOnThread();

            // for safety result
            if (fnbean != null && fnbean.SafetyMaxResultSize > 0)
            {
                return(true);
            }

            // for unsupported paging (ConditionBean)
            if (fnbean != null && fnbean.IsFetchNarrowingEffective)
            {
                // for unsupported paging (Database)
                if (fnbean.IsFetchNarrowingSkipStartIndexEffective || fnbean.IsFetchNarrowingLoopCountEffective)
                {
                    return(true);
                }

                // for auto paging (OutsideSql)
                if (OutsideSqlContext.IsExistOutsideSqlContextOnThread())
                {
                    OutsideSqlContext outsideSqlContext = OutsideSqlContext.GetOutsideSqlContextOnThread();
                    if (outsideSqlContext.IsOffsetByCursorForcedly || outsideSqlContext.IsLimitByCursorForcedly)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
示例#2
0
        public static void SaveAllContextOnThread()
        {
            if (!IsExistContextStackOnThread())
            {
                Thread.SetData(_slot, new Stack <ContextStack>());
            }
            ContextStack contextStack = new ContextStack();

            if (ConditionBeanContext.IsExistConditionBeanOnThread())
            {
                contextStack.ConditionBean = ConditionBeanContext.GetConditionBeanOnThread();
            }
            if (OutsideSqlContext.IsExistOutsideSqlContextOnThread())
            {
                contextStack.OutsideSqlContext = OutsideSqlContext.GetOutsideSqlContextOnThread();
            }
            if (FetchNarrowingBeanContext.IsExistFetchNarrowingBeanOnThread())
            {
                contextStack.FetchNarrowingBean = FetchNarrowingBeanContext.GetFetchNarrowingBeanOnThread();
            }
            if (InternalMapContext.IsExistInternalMapOnThread())
            {
                contextStack.InternalMap = InternalMapContext.GetInternalMap();
            }
            GetContextStackOnThread().Push(contextStack);
        }
 protected void CloseContext()
 {
     if (FetchNarrowingBeanContext.IsExistFetchNarrowingBeanOnThread())
     {
         // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
         // Because there is possible that fetch narrowing has been ignored for manualPaging of outsideSql.
         // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
         FetchNarrowingBeanContext.GetFetchNarrowingBeanOnThread().RestoreIgnoredFetchNarrowing();
     }
     ClearAllCurrentContext();
     RestoreAllContextOnThreadIfExists();
 }
        public IDataReader CreateDataReader(IDataSource dataSource, IDbCommand cmd)
        {
            IDataReader dataReader = ExecuteReader(dataSource, cmd);

            if (!IsUseFetchNarrowingResultSetWrapper())
            {
                return(dataReader);
            }
            FetchNarrowingBean             fnbean  = FetchNarrowingBeanContext.GetFetchNarrowingBeanOnThread();
            FetchNarrowingResultSetWrapper wrapper = null;

            if (OutsideSqlContext.IsExistOutsideSqlContextOnThread())
            {
                OutsideSqlContext outsideSqlContext = OutsideSqlContext.GetOutsideSqlContextOnThread();
                wrapper = new FetchNarrowingResultSetWrapper(dataReader, fnbean
                                                             , outsideSqlContext.IsOffsetByCursorForcedly
                                                             , outsideSqlContext.IsLimitByCursorForcedly);
            }
            else
            {
                wrapper = new FetchNarrowingResultSetWrapper(dataReader, fnbean, false, false);
            }
            return(wrapper);
        }