public IEnumerable <Appreciate> List() { SqlDataReader reader = GetSqlDataReader("SELECT * FROM Tb_Appreciate"); while (reader.Read()) { Appreciate appreciate = new Appreciate { ID = reader.GetGuid(0), Title = reader.GetString(1), Times = reader.GetString(2), Author = reader.GetString(3) }; yield return(appreciate); } reader.Close(); CloseConnection(); }
public IEnumerable <Appreciate> Times(string times) { using (SqlCommand command = _connection.CreateCommand()) { command.CommandText = "SELECT * FROM Tb_Appreciate WHERE Times=@times"; command.Parameters.AddWithValue("@times", times); SqlDataReader reader = GetSqlDataReader(command); while (reader.Read()) { Appreciate appreciate = new Appreciate { ID = reader.GetGuid(0), Title = reader.GetString(1), Times = reader.GetString(2), Author = reader.GetString(3) }; yield return(appreciate); } reader.Close(); CloseConnection(); } }