/// <summary> /// Retrieve the dataset based off the index and project. Limit it /// to the first dataset found with the correct index. The index is /// auto incremented so there should only be 1 ensemble per index. /// </summary> /// <param name="cnn">Sqlite Database Connection.</param> /// <param name="project">Project containing the ensemble.</param> /// <param name="index">Row ID</param> /// <returns>Dataset based off the Row ID given.</returns> public DataSet.Ensemble QueryForDataSet(SQLiteConnection cnn, Project project, long index) { // Query for the ensemble string queryEns = String.Format("SELECT * FROM {0} WHERE ID={1} LIMIT 1;", DbCommon.TBL_ENS_ENSEMBLE, index.ToString()); DataTable data = DbCommon.GetDataTableFromProjectDb(cnn, project, queryEns); if (data.Rows.Count > 0) { DataSet.Ensemble dataset = ParseDataTables(project, data.Rows[0]); return(dataset); } return(null); }
/// <summary> /// Get a list of ensembles from the database. This will query for a list of /// rows from the database starting from the index and getting the size given. /// Then parse and add the data to the list. /// </summary> /// <param name="project">Project containing the ensemble.</param> /// <param name="index">Row ID</param> /// <param name="size">Number of ensembles to get from the database.</param> /// <returns>List of dataset based off the Row ID given and size.</returns> public Cache <long, DataSet.Ensemble> QueryForDataSet(Project project, long index, uint size) { Cache <long, DataSet.Ensemble> cache = new Cache <long, DataSet.Ensemble>(size); // Query for the ensemble string queryEns = String.Format("SELECT * FROM {0} WHERE ID>={1} LIMIT {2};", DbCommon.TBL_ENS_ENSEMBLE, index.ToString(), size.ToString()); DataTable data = DbCommon.GetDataTableFromProjectDb(project, queryEns); foreach (DataRow row in data.Rows) { int id = 0; try { id = Convert.ToInt32(row[DbCommon.COL_ENS_ID]); } catch (Exception) { } DataSet.Ensemble dataset = ParseDataTables(project, row); cache.Add(id, dataset); } return(cache); }