查询
获取查询结果的单个值:
[HttpGet("Count")] public async Task<ActionResult> GetCount() { using IDbConnection con = new SqlConnection(MyConfig.ConnectionString); string sql = "select count(*) from T_Book "; var count = await con.ExecuteScalarAsync(sql);// 返回dynamic类型 return Ok(count); } [HttpGet("CountInt")] public async Task<ActionResult> GetCountInt() { using IDbConnection con = new SqlConnection(MyConfig.ConnectionString); string sql = "select count(*) from T_Book"; int count = await con.ExecuteScalarAsync<int>(sql);//返回整形 return Ok(count); }
标签:count,HttpGet,使用,Book,sql,SqlConnection,Dapper,con From: https://www.cnblogs.com/friend/p/16753318.html