/// <summary>
        /// AddParameter
        /// </summary>
        /// <param name="value">参数值</param>
        /// <returns>参数名称</returns>
        public string AddParameter(object value)
        {
            string name = string.Format("p_{0}", _parameters.Count + 1);

            _parameters.Add(name, SqliteDataBase.CreateParameter(name, value));
            return(name);
        }
Example #2
0
 private SqliteDataBaseScope(SqliteDataBase dataBase, bool trans = false)
 {
     _dataBase = dataBase;
     if (dataBase.QuoteCount <= 0)
     {
         dataBase.Open();
     }
     else
     {
         dataBase.QuoteCount += 1;
     }
     if (!trans || dataBase.Transaction == null)
     {
         return;
     }
     this._isHearTransaction = true;
     dataBase.Transaction    = dataBase.Connection.BeginTransaction();
 }
        /// <summary>
        /// AddParameter
        /// </summary>
        /// <param name="name">参数名(无名称使用序号)</param>
        /// <param name="value">参数值</param>
        /// <returns>True表示设置到旧参数,False表示增加了一个参数</returns>
        public bool SetParameterValue(string name, object value)
        {
            if (name == null)
            {
                name = string.Format("p_{0}", _parameters.Count + 1);
                _parameters.Add(name, SqliteDataBase.CreateParameter(name, value));
                return(false);
            }
            SQLiteParameter parameter;

            if (this._parameters.TryGetValue(name, out parameter))
            {
                parameter.Value = value;
                return(true);
            }
            _parameters.Add(name, SqliteDataBase.CreateParameter(name, value));
            return(false);
        }
Example #4
0
 public static SqliteDataBaseScope CreateScope(SqliteDataBase dataBase, bool trans = false)
 {
     return(new SqliteDataBaseScope(dataBase, trans));
 }