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);
        }
Ejemplo n.º 2
0
 /**
  * Set fetch-narrowing-bean context on thread.
  *
  * @param cb FetchNarrowing-bean. (NotNull)
  */
 public static void SetFetchNarrowingBeanOnThread(FetchNarrowingBean cb)
 {
     if (cb == null)
     {
         String msg = "The argument[cb] must not be null.";
         throw new ArgumentNullException(msg);
     }
     Thread.SetData(_fetchNarrowingBeanSlot, cb);
 }
Ejemplo n.º 3
0
        // ===============================================================================
        //                                                                     Constructor
        //                                                                     ===========
        public FetchNarrowingResultSetWrapper(System.Data.IDataReader dataReader, FetchNarrowingBean fetchNarrowingBean
                                              , bool offsetByCursorForcedly, bool limitByCursorForcedly)
        {
            _dataReader             = dataReader;
            _fetchNarrowingBean     = fetchNarrowingBean;
            _offsetByCursorForcedly = offsetByCursorForcedly;
            _limitByCursorForcedly  = limitByCursorForcedly;

            skip();
        }
Ejemplo n.º 4
0
        protected void SetupOutsideSqlFetchNarrowingBean(Object pmb, OutsideSqlOption option)
        {
            if (pmb == null || !FetchNarrowingBeanContext.IsTheTypeFetchNarrowingBean(pmb.GetType()))
            {
                return;
            }
            FetchNarrowingBean fetchNarrowingBean = (FetchNarrowingBean)pmb;

            if (option.IsManualPaging)
            {
                fetchNarrowingBean.IgnoreFetchNarrowing();
            }
            FetchNarrowingBeanContext.SetFetchNarrowingBeanOnThread(fetchNarrowingBean);
        }
Ejemplo n.º 5
0
        public static void RestoreAllContextOnThreadIfExists()
        {
            if (!IsExistContextStackOnThread())
            {
                return;
            }
            Stack <ContextStack> stackOnThread = GetContextStackOnThread();

            if (stackOnThread.Count == 0)
            {
                ClearContextStackOnThread();
                return;
            }
            ContextStack  contextStack = stackOnThread.Pop();
            ConditionBean cb           = contextStack.ConditionBean;

            if (cb != null)
            {
                ConditionBeanContext.SetConditionBeanOnThread(cb);
            }
            OutsideSqlContext outsideSqlContext = contextStack.OutsideSqlContext;

            if (outsideSqlContext != null)
            {
                OutsideSqlContext.SetOutsideSqlContextOnThread(outsideSqlContext);
            }
            FetchNarrowingBean fetchNarrowingBean = contextStack.FetchNarrowingBean;

            if (fetchNarrowingBean != null)
            {
                FetchNarrowingBeanContext.SetFetchNarrowingBeanOnThread(fetchNarrowingBean);
            }
            IDictionary <String, Object> internalMap = contextStack.InternalMap;

            if (internalMap != null)
            {
                InternalMapContext.ClearInternalMapOnThread();
                foreach (String key in internalMap.Keys)
                {
                    Object value = internalMap[key];
                    InternalMapContext.SetObject(key, value);
                }
            }
        }
        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);
        }