/// <summary> /// Fetches a single row by ID. /// </summary> /// <param name="output"></param> /// <param name="id"></param> /// <returns></returns> public static bool FetchById(ref ShipEquipment output, int id) { SQLiteDataReader reader = DBI.DoPreparedQuery( @"SELECT id, hull, ship, 0 AS count FROM ShipEquipment WHERE id = @id;" , new Tuple <string, object>("@id", id)); if (reader != null && reader.Read()) { output = ShipEquipment.Factory(reader); return(true); } return(false); }
/// <summary> /// Fetches the count of a certain hull on a ship /// </summary> /// <param name="output"></param> /// <param name="hullId"></param> /// <param name="shipId"></param> /// <returns></returns> public static bool FetchHullByShip(ref ShipEquipment output, int hullId, int shipId) { SQLiteDataReader reader = DBI.DoPreparedQuery( @"SELECT id, hull, ship, COUNT(id) AS count FROM ShipEquipment WHERE ship = @ship AND hull = @hull GROUP BY hull;" , new Tuple <string, object>("@ship", shipId), new Tuple <string, object>("@hull", hullId)); if (reader != null && reader.Read()) { output = ShipEquipment.Factory(reader); return(true); } return(false); }
/// <summary> /// Selects all hulls embarked on a given ship /// </summary> /// <param name="output"></param> /// <param name="shipId"></param> /// <returns></returns> public static bool FetchAllByShip(ref List <ShipEquipment> output, int shipId) { output = new List <ShipEquipment>(); SQLiteDataReader reader = DBI.DoPreparedQuery( @"SELECT 0 AS id, hull, ship, COUNT(id) AS count FROM ShipEquipment WHERE ship = @ship GROUP BY hull;" , new Tuple <string, object>("@ship", shipId)); while (reader != null && reader.Read()) { output.Add(ShipEquipment.Factory(reader)); } return(true); }