public static PageData <T> QueryPage(int page, int size, string where = null, string orderBy = null) { using (var conn = new MySqlConnection(ConnectionString4Slave)) { string sql1 = MySqlDapper.GetSqlToQueryTotalRow(tableInfo, where); int totalRow = conn.ExecuteScalar <int>(sql1); int totalPage = (int)Math.Floor((decimal)(totalRow + size - 1) / size); int offset = page * size; string sql2 = MySqlDapper.GetSqlToQueryPage(tableInfo, offset, size, where, orderBy); var list = MySqlDapper.Query <T>(ConnectionString4Slave, sql2); return(new PageData <T>() { TotalRow = totalRow, TotalPage = totalPage, List = list }); } }
public static List <T> Query(string where = null, string orderBy = null) { string sql = MySqlDapper.GetSqlToQuery(tableInfo, where, orderBy); return(MySqlDapper.Query <T>(ConnectionString4Slave, sql)); }
public ActionResult CheckDBConnection() { _dapper.Query <string>("select top 1 * from account").FirstOrDefault(); return(Ok("Db Connection is okay")); }