示例#1
0
        /// <summary>
        /// 执行增删改SQL语句。
        /// </summary>
        /// <param name="sql">增删改SQL语句。</param>
        /// <param name="param">SQL语句参数。</param>
        public void Execute(string sql, object param = null)
        {
            var command = CommandCache.GetCommand(sql, param);

            commands.Add(command);
        }
示例#2
0
        /// <summary>
        /// 执行查询SQL语句,返回指定类型的标量。
        /// </summary>
        /// <typeparam name="T">标量类型。</typeparam>
        /// <param name="sql">查询SQL语句。</param>
        /// <param name="param">SQL语句参数。</param>
        /// <returns>指定类型的标量。</returns>
        public T Scalar <T>(string sql, object param = null)
        {
            var command = CommandCache.GetCommand(sql, param);

            return((T)database.Scalar(command));
        }
示例#3
0
        /// <summary>
        /// 根据表名及参数删除数据。
        /// </summary>
        /// <param name="tableName">表名。</param>
        /// <param name="parameters">命令参数字典。</param>
        public void Delete(string tableName, Dictionary <string, object> parameters)
        {
            var command = CommandCache.GetDeleteCommand(tableName, parameters);

            commands.Add(command);
        }
示例#4
0
        /// <summary>
        /// 根据表名及参数修改数据。
        /// </summary>
        /// <param name="tableName">表名。</param>
        /// <param name="keyFields">主键字段名,多个用“,”分割。</param>
        /// <param name="parameters">命令参数字典。</param>
        public void Update(string tableName, string keyFields, Dictionary <string, object> parameters)
        {
            var command = CommandCache.GetUpdateCommand(tableName, keyFields, parameters);

            commands.Add(command);
        }
示例#5
0
        /// <summary>
        /// 根据表名及参数查询数据表。
        /// </summary>
        /// <param name="tableName">表名。</param>
        /// <param name="parameters">命令参数字典。</param>
        /// <returns>数据表。</returns>
        public DataTable SelectTable(string tableName, Dictionary <string, object> parameters)
        {
            var command = CommandCache.GetSelectCommand(tableName, parameters);

            return(database.Query(command));
        }
示例#6
0
        /// <summary>
        /// 执行查询SQL语句,返回数据表。
        /// </summary>
        /// <param name="sql">查询SQL语句。</param>
        /// <param name="param">SQL语句参数。</param>
        /// <returns>数据表。</returns>
        public DataTable QueryTable(string sql, object param = null)
        {
            var command = CommandCache.GetCommand(sql, param);

            return(database.Query(command));
        }
示例#7
0
        /// <summary>
        /// 删除实体对象。
        /// </summary>
        /// <typeparam name="T">实体类型。</typeparam>
        /// <param name="entity">实体对象。</param>
        public void Delete <T>(T entity) where T : EntityBase
        {
            var command = CommandCache.GetDeleteCommand(entity);

            commands.Add(command);
        }