public static Project GetProject(IDatabaseProvider db, int id) { if (db == null) { throw new ArgumentNullException(nameof(db)); } ProjectsTableAdapter tableAdapter = db.DB.ProjectsTableAdapter; PeygirDatabaseDataSet.ProjectsDataTable rows = tableAdapter.GetDataByID(id); if (rows.Count == 1) { // Found. Project project = new Project(rows[0]); return(project); } // Not found. return(null); }
public static Project[] GetProjects(IDatabaseProvider db) { if (db == null) { throw new ArgumentNullException(nameof(db)); } ProjectsTableAdapter tableAdapter = db.DB.ProjectsTableAdapter; PeygirDatabaseDataSet.ProjectsDataTable rows = tableAdapter.GetData(); // Create list. List <Project> projects = new List <Project>(); foreach (var row in rows) { // Add. Project project = new Project(row); projects.Add(project); } return(projects.ToArray()); }