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 Map <String, String> GetSelectIndexReverseMap() // ResourceContext in Java { if (!ConditionBeanContext.IsExistConditionBeanOnThread()) { return(null); } ConditionBean cb = ConditionBeanContext.GetConditionBeanOnThread(); return(cb.SqlClause.getSelectIndexReverseMap()); }
protected Map <String, int?> GetSelectIndexMap() // RelationRowCreationResource in Java { if (!ConditionBeanContext.IsExistConditionBeanOnThread()) { return(null); } ConditionBean cb = ConditionBeanContext.GetConditionBeanOnThread(); return(cb.SqlClause.getSelectIndexMap()); }
// =============================================================================== // Context Helper // ============== protected void InitializeContext() { if (ConditionBeanContext.IsExistConditionBeanOnThread() || OutsideSqlContext.IsExistOutsideSqlContextOnThread() || FetchNarrowingBeanContext.IsExistFetchNarrowingBeanOnThread() || InternalMapContext.IsExistInternalMapOnThread()) // means recursive invoking { SaveAllContextOnThread(); } ClearAllCurrentContext(); }
// =============================================================================== // 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)); }
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); }
public static void ClearAllCurrentContext() { if (ConditionBeanContext.IsExistConditionBeanOnThread()) { ConditionBeanContext.ClearConditionBeanOnThread(); } if (OutsideSqlContext.IsExistOutsideSqlContextOnThread()) { OutsideSqlContext.ClearOutsideSqlContextOnThread(); } if (FetchNarrowingBeanContext.IsExistFetchNarrowingBeanOnThread()) { FetchNarrowingBeanContext.ClearFetchNarrowingBeanOnThread(); } if (InternalMapContext.IsExistInternalMapOnThread()) { InternalMapContext.ClearInternalMapOnThread(); } }
// =================================================================================== // ConditionBean // ============= protected bool HasConditionBean() { return(ConditionBeanContext.IsExistConditionBeanOnThread()); }
protected bool HasConditionBean(RelationRowCreationResource res) { return(ConditionBeanContext.IsExistConditionBeanOnThread()); }