protected String buildPaging(filtering.Paging pg) { String str = ""; if (pg != null) { str += " " + (pg.PageNumber * pg.CountPerPage) + "," + pg.CountPerPage + " "; } return(str); }
public override System.Data.DataTable getFiltered(String tableName, filtering.BaseFilter filter = null, filtering.Sort sort = null, filtering.Paging page = null) { int status = -1; System.Data.DataTable results = new System.Data.DataTable(); MySql.Data.MySqlClient.MySqlConnection dbConn = this.ConnectAsync() as MySql.Data.MySqlClient.MySqlConnection; if (dbConn != null && dbConn.State == System.Data.ConnectionState.Open) { String sql = ""; try { sql = "Select * from `" + tableName + "` "; // build filter if (filter != null) { sql += " Where " + buildFilter(filter); } // build sort if (sort != null) { sql += " ORDER BY " + buildSort(sort); } // build paging if (page != null) { sql += " LIMIT " + buildPaging(page); } var cmd = dbConn.CreateCommand(); cmd.CommandText = sql; results = parseResults(cmd.ExecuteReader()); status = 0; } catch (Exception ex) { if (m_DebugInfo) { Console.WriteLine("Error [{0}]: {1}", tableName, ex.Message); } status = -2; } finally { if (dbConn != null) { try { dbConn.Close(); } finally { dbConn.Dispose(); } } } decrementOpenConnections(); } return(results); }