public List<Priority> GetAllPriorities() { using (var connection = new SqlConnection(this._connectionString)) { connection.Open(); using (var command = new SqlCommand()) { command.Connection = connection; command.CommandText = SELECT_SECTIONS; command.CommandType = System.Data.CommandType.Text; using (var reader = command.ExecuteReader()) { List<Priority> listOfPriorities = new List<Priority>(); while (reader.Read()) { Priority myTask = new Priority(); myTask.PriorityId = (int)reader["Id"]; listOfPriorities.Add(myTask); } return listOfPriorities; } } } }
public List<Priority> GetAllPriorities() { using (XmlReader reader = XmlReader.Create(_connectionString)) { List<Priority> listOfPriorities = new List<Priority>(); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: break; case XmlNodeType.Text: Priority myTask = new Priority(); myTask.PriorityId = Convert.ToInt32(reader.Value); listOfPriorities.Add(myTask); break; case XmlNodeType.XmlDeclaration: case XmlNodeType.ProcessingInstruction: //reader.WriteProcessingInstruction(reader.Name, reader.Value); break; case XmlNodeType.Comment: //reader.WriteComment(reader.Value); break; case XmlNodeType.EndElement: //reader.WriteFullEndElement(); break; } } return listOfPriorities; } }