/// <summary> /// Liefert alle Personen aus der DB. /// </summary> /// <returns>Eine Liste der Personen.</returns> public List <IVersorger> GetAllByVersorgertyp(EnumStammdatenTyp versorgerTyp) { var connection = new SQLiteConnection(SQL_CONNECTION_STRING); connection.Open(); var versorger = new List <IVersorger>(); var statement = new SQLiteCommand(SQL_SELECT_ALL_BY_VERSORGERTYP, connection); statement.Parameters.Add(new SQLiteParameter("@versorgertyp", (int)versorgerTyp)); SQLiteDataReader reader = statement.ExecuteReader(); while (reader.Read()) { versorger.Add(VersorgerFactory.Create(reader.GetInt32(0), (EnumStammdatenTyp)reader.GetInt32(1), reader.GetString(2), reader.GetString(3), reader.GetString(4), reader.GetString(5), reader.GetString(6))); } connection.Close(); return(versorger); }
/// <summary> /// Liest die Daten zu einer bestimmten Person aus der DB. /// </summary> /// <param name="id">Die Id der zu ladenden Person.</param> /// <returns>Eine <see cref="IPerson"/> mit den Daten aus der DB.</returns> public IVersorger GetById(int id) { var connection = new SQLiteConnection(SQL_CONNECTION_STRING); connection.Open(); IVersorger versorger = null; var statement = new SQLiteCommand(SQL_GET_BY_ID, connection); statement.Parameters.Add(new SQLiteParameter("@id", id)); SQLiteDataReader reader = statement.ExecuteReader(); while (reader.Read()) { versorger = VersorgerFactory.Create(reader.GetInt32(0), (EnumStammdatenTyp)reader.GetInt32(1), reader.GetString(2), reader.GetString(3), reader.GetString(4), reader.GetString(5), reader.GetString(6)); } connection.Close(); return(versorger); }