DbCommand.ExecuteScalar 方法 执行查询,并返回查询所返回的结果集中第一行的第一列。 所有其他的列和行将被忽略。...对 ADO.NET 的 DbCommand.ExecuteScalar 方法的调用者来说,select keyword_id 和 select MAX(keyword_id) 都是一样方便的,只不过要注意根据所使用的...如果是使用 DbCommand.ExcuteReader 方法来获得查询结果: 对于第二个 select 语句,需要判断 DbDataReader.Read 方法的返回值来决定查询结果是否为空。...当然,对于查询结果最多只有一行一列的情况是不推荐使用 DbCommand.ExcuteReader 方法的。...只有查询结果有可能有多行,或者查询结果有多列的情况下,才需要使用 DbCommand.ExcuteReader 方法。
当中的拦截方法,代码如下: //如果是写入,则正常执行 public override InterceptionResult NonQueryExecuting(DbCommand...cancellationToken); } public override InterceptionResult ScalarExecuting(DbCommand..., result); } public override Task> ScalarExecutingAsync(DbCommand...Logger; } } 创建2个私有的方法,一个记录执行开始时间,一个记录SQL //记录SQL开始执行的时间 private void OnStart(DbCommand..., cancellationToken); } public override InterceptionResult ScalarExecuting(DbCommand
Command("zadd") @ParamLength(3) @ParamType(DataType.ZSET) public class SortedSetAddCommand implements DBCommand...} else { score = string; } } return zset(set); } } SortedSetAddCommand实现了DBCommand...zcard") @ParamLength(1) @ParamType(DataType.ZSET) public class SortedSetCardinalityCommand implements DBCommand...Command("zrem") @ParamLength(2) @ParamType(DataType.ZSET) public class SortedSetRemoveCommand implements DBCommand...return error("ERR value is not an integer or out of range"); } } } SortedSetRangeCommand实现了DBCommand
创建 DbCommand 对象 数据访问应用程序块提供了获取 ADO.NET DbCommand 对象的的统一方法。应用程序块的数据访问方法包含了接受 DbCommand 对象的重载。...如果用 DbCommand 对象来使用重载,在调用存储过程时将可以进行更多的控制。例如,如果使用 DbCommand 对象,就可以使用在输出参数中返回多个结果的存储过程。...另外,DbCommand 对象允许指定存储过程的超时值。...用于 SQL 语句的 DbCommand对象 使用 GetSqlStringCommand 方法创建用于内联 SQL 语句的 DbCommand 对象。...方法来创建 DbCommand 对象。
.map(RedisToken::string) .getOrElse(RedisToken::nullString); } } HashGetCommand实现了DBCommand...) { return convert(value); } else { return array(); } } } HashGetAllCommand实现了DBCommand...Command("hdel") @ParamLength(2) @ParamType(DataType.HASH) public class HashDeleteCommand implements DBCommand...removedKeys.isEmpty()); } } HashDeleteCommand实现了DBCommand接口,其execute方法先从请求参数提取keys,然后执行db.merge,该方法先获取...@Command("hkeys") @ParamLength(1) @ParamType(DataType.HASH) public class HashKeysCommand implements DBCommand
oldValue.getSet().appendAll(newValue.getSet()))); return integer(value.size()); } } SetAddCommand实现了DBCommand...Command("smembers") @ParamLength(1) @ParamType(DataType.SET) public class SetMembersCommand implements DBCommand...request.getParam(0)), DatabaseValue.EMPTY_SET); return convert(value); } } SetMembersCommand实现了DBCommand...set = db.getSet(request.getParam(0)); return integer(set.size()); } } SetCardinalityCommand实现了DBCommand...@Command("srem") @ParamLength(2) @ParamType(DataType.SET) public class SetRemoveCommand implements DBCommand
ReadOnly @Command("get") @ParamLength(1) @ParamType(DataType.STRING) public class GetCommand implements DBCommand...db, Request request) { return convert(db.get(safeKey(request.getParam(0)))); } } GetCommand实现了DBCommand...MultiGetCommand.java @ReadOnly @Command("mget") @ParamLength(1) public class MultiGetCommand implements DBCommand...claudb/command/string/SetCommand.java @Command("set") @ParamLength(2) public class SetCommand implements DBCommand...} else { key = value; } } return status("OK"); } } MultiSetCommand实现了DBCommand
key/KeysCommand.java @ReadOnly @Command("keys") @ParamLength(1) public class KeysCommand implements DBCommand...GlobPattern pattern) { return entry -> pattern.match(entry.get1().toString()); } } KeysCommand实现了DBCommand...command/key/DeleteCommand.java @Command("del") @ParamLength(1) public class DeleteCommand implements DBCommand...= null) { removed += 1; } } return integer(removed); } } DeleteCommand实现了DBCommand...value.isExpired(Instant.now()) : false); } } ExistsCommand实现了DBCommand接口,其execute方法先通过db.get(safeKey
@Command("lpush") @ParamLength(2) @ParamType(DataType.LIST) public class LeftPushCommand implements DBCommand...appendAll(oldValue.getList()))); return RedisToken.integer(result.size()); } } LeftPushCommand实现了DBCommand...Command("rpush") @ParamLength(2) @ParamType(DataType.LIST) public class RightPushCommand implements DBCommand...@Command("rpop") @ParamLength(1) @ParamType(DataType.LIST) public class RightPopCommand implements DBCommand...Command("llen") @ParamLength(1) @ParamType(DataType.LIST) public class ListLengthCommand implements DBCommand
SelectCommand.java @ReadOnly @Command("select") @ParamLength(1) public class SelectCommand implements DBCommand...claudb/command/server/SyncCommand.java @ReadOnly @Command("sync") public class SyncCommand implements DBCommand...} catch (IOException e) { return error("ERROR replication error"); } } } SyncCommand实现了DBCommand...)), request.getSession(), host, Integer.parseInt(port)); slave.start(); } } SlaveOfCommand实现了DBCommand....map(slave -> array(string(slave[0]), string(slave[1]), string("0"))).asList(); } } RoleCommand实现了DBCommand
SelectCommand.java @ReadOnly @Command("select") @ParamLength(1) public class SelectCommand implements DBCommand...claudb/command/server/SyncCommand.java @ReadOnly @Command("sync") public class SyncCommand implements DBCommand...} catch (IOException e) { return error("ERROR replication error"); } } } SyncCommand实现了DBCommand...), request.getSession(), host, Integer.parseInt(port)); slave.start(); } } SlaveOfCommand实现了DBCommand....map(slave -> array(string(slave[0]), string(slave[1]), string("0"))).asList(); } } RoleCommand实现了DBCommand
对象或sql语句 返回受影响的行数 ExecuteReader 执行传入的Dbcommand对象或sql,返回支持IDdataReader接口的类的实例...ExecuteDataSet 执行传入的Dbcommand对象或sql,返回DataSet对象 ExecuteScalar 执行传入的Dbcommand...为Dbcommand对象传入一个新的输入参数对象 AddOutParameter 为Dbcommand对象传入一个新的输出参数对象- GetParameterValue...获取Dbcommand对象指定名称的参数的值 SetParameterValue 为Dbcommand对象指定名称的参数赋值 GetSqlStringCommand...依据传入的SQl语句获取一个DBcommand对象 GetStoredProcCommand 依据传入的存储过程获取一个DBcommand对象
@Command("lpush") @ParamLength(2) @ParamType(DataType.LIST) public class LeftPushCommand implements DBCommand...appendAll(oldValue.getList()))); return RedisToken.integer(result.size()); } } LeftPushCommand实现了DBCommand...Command("rpush") @ParamLength(2) @ParamType(DataType.LIST) public class RightPushCommand implements DBCommand...@Command("rpop") @ParamLength(1) @ParamType(DataType.LIST) public class RightPopCommand implements DBCommand...Command("llen") @ParamLength(1) @ParamType(DataType.LIST) public class ListLengthCommand implements DBCommand
dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "BookPlaceID", DbType.AnsiString...dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "BookPlaceName",...dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "BookPlaceID", DbType.Int32...(dbCommand, "BookPlaceParent", DbType.Int32, model.BookPlaceParent); i= db.ExecuteNonQuery(dbCommand)...dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "bookPlaceID", DbType.AnsiString
GetStoredProcCommond(string storedProcedure) { DbCommand dbCommand = connection.CreateCommand...(); dbCommand.CommandText = storedProcedure; dbCommand.CommandType = CommandType.StoredProcedure...; return dbCommand; } public DbCommand GetSqlStringCommond(string sqlQuery) {...DbCommand dbCommand = connection.CreateCommand(); dbCommand.CommandText = sqlQuery; dbCommand.CommandType...(DbCommand cmd, DbParameterCollection dbParameterCollection) { foreach (DbParameter dbParameter
pubsub/PublishCommand.java @Command("publish") @ParamLength(2) public class PublishCommand implements DBCommand...pcount = patternPublish(server, channel, message); return count + pcount; } } PublishCommand实现了DBCommand...ReadOnly @Command("subscribe") @ParamLength(1) @PubSubAllowed public class SubscribeCommand implements DBCommand...) { return getSessionState(request.getSession()).getSubscriptions(); } } UnsubscribeCommand实现了DBCommand...Command("psubscribe") @ParamLength(1) @PubSubAllowed public class PatternSubscribeCommand implements DBCommand
领取专属 10元无门槛券
手把手带您无忧上云