/// <summary> /// Get all the children of an individual, which is identified by both PedigreeID and IndividiaulID /// </summary> /// <param name="PedigreeID">The pedigree ID of that individual</param> /// <param name="IndividualID">The individual ID of that individual</param> /// <returns>Return a list of pairs of pedigree ID and individual ID</returns> public List<Individual> GetChildren(long PedigreeID, long IndividualID) { DataTable t; //The individual could be only mother or father, not both. //Therefore the following SQL is safe not to get redundant tuples db.ExecuteQuery(out t, "SELECT * FROM Individuals WHERE PedigreeID = {0} AND (MotherID = {1} OR FatherID = {1})",PedigreeID, IndividualID); if (t != null) { List<Individual> children = new List<Individual>(); foreach (DataRow r in t.Rows) { Individual i = new Individual((int)r["PedigreeID"], (int)r["IndividualID"], (int)r["Gender"], (int)r["MotherID"], (int)r["FatherID"]); children.Add(i); } return children; } else return null; }
/// <summary> /// Return all the individuals without parents for a specific pedigree graph /// </summary> /// <param name="PedigreeID">The pedigree ID</param> /// <returns>A list of indiviudals which don't have parents</returns> public List<Individual> IndividualsWOParents(long PedigreeID) { DataTable t; db.ExecuteQuery(out t, "SELECT * FROM Individuals WHERE PedigreeID = {0} AND MotherID = -1 AND FatherID = -1", PedigreeID); if (t != null) { List<Individual> indis = new List<Individual>(); foreach (DataRow r in t.Rows) { Individual i = new Individual((int)r["PedigreeID"], (int)r["IndividualID"], (int)r["Gender"], (int)r["MotherID"], (int)r["FatherID"]); indis.Add(i); } return indis; } else return null; }