/// <summary>
    /// This function attempts to map all parameters in the collection to all statements in a Command.
    /// Since named parameters may span multiple statements, this function makes sure all statements are bound
    /// to the same named parameter.  Unnamed parameters are bound in sequence.
    /// </summary>
    internal void MapParameters(SQLiteStatement activeStatement)
    {
      if (_unboundFlag == false || _parameterList.Count == 0 || _command._statementList == null) return;

      int nUnnamed = 0;
      string s;
      int n;
      int y = -1;
      SQLiteStatement stmt;

      foreach(SQLiteParameter p in _parameterList)
      {
        y ++;
        s = p.ParameterName;
        if (s == null)
        {
          s = String.Format(CultureInfo.InvariantCulture, ";{0}", nUnnamed);
          nUnnamed++;
        }

        int x;
        bool isMapped = false;

        if (activeStatement == null)
          x = _command._statementList.Count;
        else
          x = 1;

        stmt = activeStatement;
        for (n = 0; n < x; n++)
        {
          isMapped = false;
          if (stmt == null) stmt = _command._statementList[n];
          if (stmt._paramNames != null)
          {
            if (stmt.MapParameter(s, p) == true)
              isMapped = true;
          }
          stmt = null;
        }

        // If the parameter has a name, but the SQL statement uses unnamed references, this can happen -- attempt to map
        // the parameter by its index in the collection
        if (isMapped == false)
        {
          s = String.Format(CultureInfo.InvariantCulture, ";{0}", y);

          stmt = activeStatement;
          for (n = 0; n < x; n++)
          {
            if (stmt == null) stmt = _command._statementList[n];
            if (stmt._paramNames != null)
            {
              if (stmt.MapParameter(s, p) == true)
                isMapped = true;
            }
            stmt = null;
          }
        }
      }
      if (activeStatement == null) _unboundFlag = false;
    }
        /// <summary>
        /// This function attempts to map all parameters in the collection to all statements in a Command.
        /// Since named parameters may span multiple statements, this function makes sure all statements are bound
        /// to the same named parameter.  Unnamed parameters are bound in sequence.
        /// </summary>
        internal void MapParameters(SQLiteStatement activeStatement)
        {
            if (_unboundFlag == false || _parameterList.Count == 0 || _command._statementList == null)
            {
                return;
            }

            int             nUnnamed = 0;
            string          s;
            int             n;
            int             y = -1;
            SQLiteStatement stmt;

            foreach (SQLiteParameter p in _parameterList)
            {
                y++;
                s = p.ParameterName;
                if (s == null)
                {
                    s = String.Format(CultureInfo.InvariantCulture, ";{0}", nUnnamed);
                    nUnnamed++;
                }

                int  x;
                bool isMapped = false;

                if (activeStatement == null)
                {
                    x = _command._statementList.Count;
                }
                else
                {
                    x = 1;
                }

                stmt = activeStatement;
                for (n = 0; n < x; n++)
                {
                    isMapped = false;
                    if (stmt == null)
                    {
                        stmt = _command._statementList[n];
                    }
                    if (stmt._paramNames != null)
                    {
                        if (stmt.MapParameter(s, p) == true)
                        {
                            isMapped = true;
                        }
                    }
                    stmt = null;
                }

                // If the parameter has a name, but the SQL statement uses unnamed references, this can happen -- attempt to map
                // the parameter by its index in the collection
                if (isMapped == false)
                {
                    s = String.Format(CultureInfo.InvariantCulture, ";{0}", y);

                    stmt = activeStatement;
                    for (n = 0; n < x; n++)
                    {
                        if (stmt == null)
                        {
                            stmt = _command._statementList[n];
                        }
                        if (stmt._paramNames != null)
                        {
                            if (stmt.MapParameter(s, p) == true)
                            {
                                isMapped = true;
                            }
                        }
                        stmt = null;
                    }
                }
            }
            if (activeStatement == null)
            {
                _unboundFlag = false;
            }
        }
示例#3
0
 internal void MapParameters(SQLiteStatement activeStatement)
 {
     if ((this._unboundFlag && (this._parameterList.Count != 0)) && (this._command._statementList != null))
     {
         int num  = 0;
         int num3 = -1;
         foreach (SQLiteParameter parameter in this._parameterList)
         {
             int count;
             num3++;
             string parameterName = parameter.ParameterName;
             if (parameterName == null)
             {
                 parameterName = string.Format(CultureInfo.InvariantCulture, ";{0}", new object[] { num });
                 num++;
             }
             bool flag = false;
             if (activeStatement == null)
             {
                 count = this._command._statementList.Count;
             }
             else
             {
                 count = 1;
             }
             SQLiteStatement statement = activeStatement;
             int             num2      = 0;
             while (num2 < count)
             {
                 flag = false;
                 if (statement == null)
                 {
                     statement = this._command._statementList[num2];
                 }
                 if ((statement._paramNames != null) && statement.MapParameter(parameterName, parameter))
                 {
                     flag = true;
                 }
                 statement = null;
                 num2++;
             }
             if (!flag)
             {
                 parameterName = string.Format(CultureInfo.InvariantCulture, ";{0}", new object[] { num3 });
                 statement     = activeStatement;
                 for (num2 = 0; num2 < count; num2++)
                 {
                     if (statement == null)
                     {
                         statement = this._command._statementList[num2];
                     }
                     if ((statement._paramNames != null) && statement.MapParameter(parameterName, parameter))
                     {
                         flag = true;
                     }
                     statement = null;
                 }
             }
         }
         if (activeStatement == null)
         {
             this._unboundFlag = false;
         }
     }
 }