Ejemplo n.º 1
0
 /// <summary>
 /// 支持ExecuteScalar,返回object
 /// </summary>
 /// <param name="parameters">参数</param>
 /// <param name="sqlName">sql名称</param>
 /// <returns></returns>
 public object ExecuteScalarRead(HashObject parameters, string sqlName)
 {
     using (DbHelperWrapper dbhelper = new DbHelperWrapper(this._dbrwType, this._dbName, this._tableName, sqlName, parameters))
     {
         dbhelper.LogEnable = this.LogEnable;
         object result = dbhelper.ExecuteScalarRead();
         return(result);
     }
 }
Ejemplo n.º 2
0
        ///// <summary>
        ///// 根据主键返回一条数据
        ///// </summary>
        ///// <param name="id">主键id</param>
        ///// <returns></returns>
        //public HashObject GetData(long id)
        //{
        //    HashObject parameters = new HashObject();
        //    parameters.Add(this._primaryColumn, id);

        //    HashObject result = GetData(parameters);

        //    return result;
        //}


        /// <summary>
        /// 计算符合条件的数据条数
        /// </summary>
        /// <param name="whereParameters">条件参数</param>
        /// <returns></returns>
        public int Count(HashObject whereParameters)
        {
            string sql = SchemaManager.GetCountSQL(this._dbName, this._tableName, whereParameters);

            using (DbHelperWrapper dbhelper = new DbHelperWrapper(this._dbrwType, this._dbName, this._tableName, sql, whereParameters, SqlType.CmdText))
            {
                dbhelper.LogEnable = this.LogEnable;
                object result = dbhelper.ExecuteScalarRead();
                return(Convert.ToInt32(result));
            }
        }