protected bool AddSetReturnParamValuesStatements(IList statements, CodeExpression commandExpression)
        {
            int count = 0;

            if (this.activeCommand.Parameters != null)
            {
                count = this.activeCommand.Parameters.Count;
            }
            for (int i = 0; i < count; i++)
            {
                DesignParameter parameter = this.activeCommand.Parameters[i];
                if (parameter == null)
                {
                    throw new DataSourceGeneratorException("Parameter type is not DesignParameter.");
                }
                if ((parameter.Direction == ParameterDirection.Output) || (parameter.Direction == ParameterDirection.InputOutput))
                {
                    Type           parameterUrtType = this.GetParameterUrtType(parameter);
                    string         nameFromList     = this.nameHandler.GetNameFromList(parameter.ParameterName);
                    CodeExpression returnParam      = CodeGenHelper.Property(CodeGenHelper.Indexer(CodeGenHelper.Property(commandExpression, "Parameters"), CodeGenHelper.Primitive(i)), "Value");
                    CodeExpression cond             = CodeGenHelper.GenerateDbNullCheck(returnParam);
                    CodeExpression right            = CodeGenHelper.GenerateNullExpression(parameterUrtType);
                    CodeStatement  trueStm          = null;
                    if (right == null)
                    {
                        if (parameter.AllowDbNull && parameterUrtType.IsValueType)
                        {
                            trueStm = CodeGenHelper.Assign(CodeGenHelper.Argument(nameFromList), CodeGenHelper.New(CodeGenHelper.NullableType(parameterUrtType), new CodeExpression[0]));
                        }
                        else if (parameter.AllowDbNull && !parameterUrtType.IsValueType)
                        {
                            trueStm = CodeGenHelper.Assign(CodeGenHelper.Argument(nameFromList), CodeGenHelper.Primitive(null));
                        }
                        else
                        {
                            trueStm = CodeGenHelper.Throw(CodeGenHelper.GlobalType(typeof(StrongTypingException)), System.Design.SR.GetString("CG_ParameterIsDBNull", new object[] { nameFromList }), CodeGenHelper.Primitive(null));
                        }
                    }
                    else
                    {
                        trueStm = CodeGenHelper.Assign(CodeGenHelper.Argument(this.nameHandler.GetNameFromList(parameter.ParameterName)), right);
                    }
                    CodeStatement falseStm = null;
                    if (parameter.AllowDbNull && parameterUrtType.IsValueType)
                    {
                        falseStm = CodeGenHelper.Assign(CodeGenHelper.Argument(nameFromList), CodeGenHelper.New(CodeGenHelper.NullableType(parameterUrtType), new CodeExpression[] { CodeGenHelper.Cast(CodeGenHelper.GlobalType(parameterUrtType), returnParam) }));
                    }
                    else
                    {
                        falseStm = CodeGenHelper.Assign(CodeGenHelper.Argument(nameFromList), CodeGenHelper.Cast(CodeGenHelper.GlobalType(parameterUrtType), returnParam));
                    }
                    statements.Add(CodeGenHelper.If(cond, trueStm, falseStm));
                }
            }
            return(true);
        }
        private bool AddReturnStatements(IList statements)
        {
            int returnParameterPosition = base.GetReturnParameterPosition(base.activeCommand);

            if (((base.methodSource.DbObjectType == DbObjectType.Function) && (base.methodSource.QueryType != QueryType.Scalar)) && (returnParameterPosition >= 0))
            {
                DesignParameter parameter        = base.activeCommand.Parameters[returnParameterPosition];
                Type            parameterUrtType = base.GetParameterUrtType(parameter);
                CodeExpression  returnParam      = CodeGenHelper.Property(CodeGenHelper.Indexer(CodeGenHelper.Property(CodeGenHelper.Variable(QueryGeneratorBase.commandVariableName), "Parameters"), CodeGenHelper.Primitive(returnParameterPosition)), "Value");
                CodeExpression  cond             = CodeGenHelper.GenerateDbNullCheck(returnParam);
                CodeExpression  expr             = CodeGenHelper.GenerateNullExpression(parameterUrtType);
                CodeStatement   trueStm          = null;
                if (expr == null)
                {
                    if (parameter.AllowDbNull && parameterUrtType.IsValueType)
                    {
                        trueStm = CodeGenHelper.Return(CodeGenHelper.New(CodeGenHelper.NullableType(parameterUrtType), new CodeExpression[0]));
                    }
                    else if (parameter.AllowDbNull && !parameterUrtType.IsValueType)
                    {
                        trueStm = CodeGenHelper.Return(CodeGenHelper.Primitive(null));
                    }
                    else
                    {
                        trueStm = CodeGenHelper.Throw(CodeGenHelper.GlobalType(typeof(StrongTypingException)), System.Design.SR.GetString("CG_ParameterIsDBNull", new object[] { base.activeCommand.Parameters[returnParameterPosition].ParameterName }), CodeGenHelper.Primitive(null));
                    }
                }
                else
                {
                    trueStm = CodeGenHelper.Return(expr);
                }
                CodeStatement falseStm = null;
                if (parameter.AllowDbNull && parameterUrtType.IsValueType)
                {
                    falseStm = CodeGenHelper.Return(CodeGenHelper.New(CodeGenHelper.NullableType(parameterUrtType), new CodeExpression[] { CodeGenHelper.Cast(CodeGenHelper.GlobalType(parameterUrtType), returnParam) }));
                }
                else
                {
                    falseStm = CodeGenHelper.Return(CodeGenHelper.GenerateConvertExpression(returnParam, typeof(object), parameterUrtType));
                }
                statements.Add(CodeGenHelper.If(cond, trueStm, falseStm));
            }
            else if (base.methodSource.QueryType == QueryType.Scalar)
            {
                CodeExpression expression5 = CodeGenHelper.GenerateDbNullCheck(CodeGenHelper.Variable(QueryGeneratorBase.returnVariableName));
                CodeStatement  statement3  = null;
                CodeStatement  statement4  = null;
                if (base.returnType.IsValueType)
                {
                    statement3 = CodeGenHelper.Return(CodeGenHelper.New(CodeGenHelper.NullableType(base.returnType), new CodeExpression[0]));
                    statement4 = CodeGenHelper.Return(CodeGenHelper.New(CodeGenHelper.NullableType(base.returnType), new CodeExpression[] { CodeGenHelper.Cast(CodeGenHelper.GlobalType(base.returnType), CodeGenHelper.Variable(QueryGeneratorBase.returnVariableName)) }));
                }
                else
                {
                    statement3 = CodeGenHelper.Return(CodeGenHelper.Primitive(null));
                    statement4 = CodeGenHelper.Return(CodeGenHelper.Cast(CodeGenHelper.GlobalType(base.returnType), CodeGenHelper.Variable(QueryGeneratorBase.returnVariableName)));
                }
                statements.Add(CodeGenHelper.If(expression5, statement3, statement4));
            }
            else
            {
                statements.Add(CodeGenHelper.Return(CodeGenHelper.Variable(QueryGeneratorBase.returnVariableName)));
            }
            return(true);
        }