/// <summary>
        ///  Run a stored procedure, and return a single scalar value
        /// </summary>
        /// <param name="procedureName"></param>
        /// <param name="QueryParameters"></param>
        /// <param name="DB"></param>
        /// <returns></returns>
        public virtual int RunStoredProcedureScalar(IDbConnection conn, string procedureName, SqlParameter[] parameters, 
            IDbTransaction transaction=null,
            CommandBehavior commandBehavior = CommandBehavior.Default)
        {
            ProcessSql(procedureName, parameters);

            SqlParameter ReturnParameter = new SqlParameter("RETURN_VALUE", SqlDbType.Int);
            ReturnParameter.Value = -1;

            using (SqlCommand cmd = new SqlCommand(procedureName, (SqlConnection)conn))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                for (int i = 0; i <= parameters.GetUpperBound(0); i++)
                {
                    cmd.Parameters.Add(parameters[i]);
                }

                ReturnParameter.Direction = ParameterDirection.ReturnValue;

                cmd.Parameters.Add(ReturnParameter);

                ExecuteSqlFinal(new Action(() =>
                {
                    cmd.ExecuteScalar();
                }));

                cmd.Parameters.Clear();
            }
            if (commandBehavior == CommandBehavior.CloseConnection)
            {
                conn.Close();
            }
            OnQueryComplete();
            return Convert.ToInt32(ReturnParameter.Value);
        }