// =============================================================================== // ConditionBean Override // ====================== protected override void SetupSelectMethodByAuto(MethodInfo methodInfo) { if (SetupInternalSelectMethodSequenceNextVal(methodInfo)) { return; } // Assert unsupported String query = _annotationReader.GetQuery(methodInfo.Name); AssertQueryAnnotationUnsupported(methodInfo, query); IDataReaderHandler handler = CreateDataReaderHandler(methodInfo); String[] argNames = MethodUtil.GetParameterNames(methodInfo); Type[] argTypes = MethodUtil.GetParameterTypes(methodInfo); SelectDynamicCommand cmd = CreateSelectDynamicCommand(handler); if (argTypes.Length == 1 && ValueTypes.GetValueType(argTypes[0]) == ValueTypes.OBJECT) { argNames = new String[] { "pmb" }; AssertAutoQueryByDtoUnsupported(methodInfo, argTypes); S2DaoSelectDynamicCommand dynamicCommand = CreateCustomizeSelectDynamicCommand(handler); cmd = dynamicCommand; } else { HandleAutoQueryByArgsAnnotationUnsupported(methodInfo, argNames); } cmd.ArgNames = argNames; cmd.ArgTypes = argTypes; _sqlCommands[methodInfo.Name] = cmd; }
// ------------------------------------------------- // 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); }
protected Object ExecuteOutsideSqlAsDynamic(Object[] args, OutsideSqlContext outsideSqlContext) { Object firstArg = args[0]; PropertyInfo[] properties = firstArg.GetType().GetProperties(); String filteredSql = this.Sql; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Resolve embedded comment for parsing bind variable comment in embedded comment. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - for (int i = 0; i < properties.Length; i++) { PropertyInfo propertyInfo = properties[i]; Type propertyType = propertyInfo.PropertyType; if (!propertyType.Equals(typeof(String))) { continue; } String outsideSqlPiece = (String)propertyInfo.GetValue(firstArg, null); if (outsideSqlPiece == null) { continue; } String embeddedComment = "/*$pmb." + propertyInfo.Name + "*/"; filteredSql = filteredSql.Replace(embeddedComment, outsideSqlPiece); } S2DaoSelectDynamicCommand outsideSqlCommand = CreateMySelectDynamicCommand(); outsideSqlCommand.ArgNames = ArgNames; outsideSqlCommand.ArgTypes = ArgTypes; outsideSqlCommand.Sql = filteredSql; // - - - - - - - - - - - - - - - - - // Find specified resultSetHandler. // - - - - - - - - - - - - - - - - - IDataReaderHandler specifiedDataReaderHandler = FindSpecifiedDataReaderHandler(args); // - - - - - - - - - // Filter arguments. // - - - - - - - - - Object[] filteredArgs; if (outsideSqlContext.IsSpecifiedOutsideSql) { Object parameterBean = outsideSqlContext.ParameterBean; filteredArgs = new Object[] { parameterBean }; } else { filteredArgs = FilterArgumentsForDataReaderHandler(args); } ICommandContext ctx = outsideSqlCommand.DoApply(filteredArgs); 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>(); AddBindVariableInfo(ctx, bindVariableList, bindVariableTypeList, bindVariableNameList); InternalBasicSelectHandler selectHandler = CreateBasicSelectHandler(ctx.Sql, specifiedDataReaderHandler); 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)); }