示例#1
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);
        }
示例#2
0
        protected bool IsSelectedForeignInfoEmpty()
        {
            if (!HasConditionBean())
            {
                return(true);
            }
            ConditionBean cb = ConditionBeanContext.GetConditionBeanOnThread();

            return(cb.SqlClause.isSelectedForeignInfoEmpty());
        }
示例#3
0
        // ===================================================================================
        //                                                                        Select Index
        //                                                                        ============
        protected Map <String, int?> GetSelectIndexMap()  // ResourceContext in Java
        {
            if (!HasConditionBean())
            {
                return(null);
            }
            ConditionBean cb = ConditionBeanContext.GetConditionBeanOnThread();

            return(cb.SqlClause.getSelectIndexMap());
        }
示例#4
0
        protected Map <String, String> GetSelectIndexReverseMap()  // ResourceContext in Java
        {
            if (!ConditionBeanContext.IsExistConditionBeanOnThread())
            {
                return(null);
            }
            ConditionBean cb = ConditionBeanContext.GetConditionBeanOnThread();

            return(cb.SqlClause.getSelectIndexReverseMap());
        }
        protected bool HasSelectedForeignInfo(RelationRowCreationResource res)
        {
            ConditionBean cb = ConditionBeanContext.GetConditionBeanOnThread();

            if (cb.SqlClause.hasSelectedForeignInfo(res.RelationNoSuffix))
            {
                return(true);
            }
            return(false);
        }
        protected Map <String, int?> GetSelectIndexMap()  // RelationRowCreationResource in Java
        {
            if (!ConditionBeanContext.IsExistConditionBeanOnThread())
            {
                return(null);
            }
            ConditionBean cb = ConditionBeanContext.GetConditionBeanOnThread();

            return(cb.SqlClause.getSelectIndexMap());
        }
        // ===============================================================================
        //                                                                         Execute
        //                                                                         =======
        public override object Execute(object[] args)
        {
            // - - - - - - - - - - - -
            // This is top execution.
            // - - - - - - - - - - - -

            if (!ConditionBeanContext.IsExistConditionBeanOnThread())
            {
                // - - - - - - - - - -
                // Execute outsideSql.
                // - - - - - - - - - -
                if (OutsideSqlContext.IsExistOutsideSqlContextOnThread())
                {
                    OutsideSqlContext outsideSqlContext = OutsideSqlContext.GetOutsideSqlContextOnThread();
                    if (outsideSqlContext.IsDynamicBinding)
                    {
                        return(ExecuteOutsideSqlAsDynamic(args, outsideSqlContext));
                    }
                    else
                    {
                        return(ExecuteOutsideSqlAsStatic(args, outsideSqlContext));
                    }
                }

                // - - - - - - - - -
                // Execute default.
                // - - - - - - - - -
                return(ExecuteDefault(args));
            }

            // - - - - - - - - - - - -
            // Execute conditionBean.
            // - - - - - - - - - - - -
            IList <Object> bindVariableList     = new System.Collections.Generic.List <Object>();
            IList <Type>   bindVariableTypeList = new System.Collections.Generic.List <Type>();
            IList <String> bindVariableNameList = new System.Collections.Generic.List <String>();

            ConditionBean cb          = ConditionBeanContext.GetConditionBeanOnThread();
            String        finalClause = SetupRealClause(args, bindVariableList, bindVariableTypeList, bindVariableNameList);

            InternalBasicSelectHandler selectHandler = CreateBasicSelectHandler(finalClause, this.dataReaderHandler);

            Object[] bindVariableArray = new Object[bindVariableList.Count];
            bindVariableList.CopyTo(bindVariableArray, 0);
            Type[] bindVariableTypeArray = new Type[bindVariableTypeList.Count];
            bindVariableTypeList.CopyTo(bindVariableTypeArray, 0);
            String[] bindVariableNameArray = new String[bindVariableNameList.Count];
            bindVariableNameList.CopyTo(bindVariableNameArray, 0);
            selectHandler.LoggingMessageSqlArgs = bindVariableArray;
            return(selectHandler.Execute(bindVariableArray, bindVariableTypeArray, bindVariableNameArray));
        }
示例#8
0
        protected StatementConfig FindStatementConfigOnThread()
        {
            StatementConfig config = null;

            if (ConditionBeanContext.IsExistConditionBeanOnThread())
            {
                ConditionBean cb = ConditionBeanContext.GetConditionBeanOnThread();
                config = cb.StatementConfig;
            }
            else if (OutsideSqlContext.IsExistOutsideSqlContextOnThread())
            {
                OutsideSqlContext context = OutsideSqlContext.GetOutsideSqlContextOnThread();
                config = context.StatementConfig;
            }
            return(config);
        }
        // -------------------------------------------------
        //                                      Setup Clause
        //                                      ------------
        protected String SetupRealClause(Object[] args, IList <Object> bindVariableList, IList <Type> bindVariableTypeList, IList <String> bindVariableNameList)
        {
            ConditionBean cb         = ConditionBeanContext.GetConditionBeanOnThread();
            String        realClause = null;

            {
                S2DaoSelectDynamicCommand dynamicCommand = CreateMySelectDynamicCommand();
                dynamicCommand.ArgNames = ArgNames;
                dynamicCommand.ArgTypes = ArgTypes;
                dynamicCommand.Sql      = cb.SqlClause.getClause();
                ICommandContext ctx = dynamicCommand.Apply(args);
                realClause = ctx.Sql;
                AddBindVariableInfo(ctx, bindVariableList, bindVariableTypeList, bindVariableNameList);
            }
            return(realClause);
        }
示例#10
0
        // You should call HasConditionBean() before calling this!
        protected bool CanRelationMappingCache()
        {
            ConditionBean cb = ConditionBeanContext.GetConditionBeanOnThread();

            return(cb.CanRelationMappingCache());
        }
示例#11
0
        // You should call HasConditionBean() before calling this!
        protected bool HasSelectedForeignInfo(String relationNoSuffix)
        {
            ConditionBean cb = ConditionBeanContext.GetConditionBeanOnThread();

            return(cb.SqlClause.hasSelectedForeignInfo(relationNoSuffix));
        }
示例#12
0
 protected ConditionBean GetConditionBean()
 {
     return(ConditionBeanContext.GetConditionBeanOnThread());
 }