public List<DataObject.Log> List() { List<DataObject.Log> list = new List<DataObject.Log>(); using (SqlConnection connection = new SqlConnection(ConnectionString)) { connection.Open(); string query = "SELECT Id, Originator, Fault, DateTimeAdded FROM [Logging].[Log] WHERE Id_LogType = 1 ORDER By Id DESC"; using (SqlCommand command = new SqlCommand(query, connection)) { SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { DataObject.Log dataObject = new DataObject.Log(); dataObject.Id = int.Parse(reader.GetValue(0).ToString()); dataObject.Originator = reader.GetValue(1).ToString(); dataObject.Fault = reader.GetValue(2).ToString(); dataObject.DateAdded = Convert.ToDateTime(reader.GetValue(3).ToString()); list.Add(dataObject); } } } } return list; }
public List <DataObject.Log> List() { List <DataObject.Log> list = new List <DataObject.Log>(); using (SqlConnection connection = new SqlConnection(ConnectionString)) { connection.Open(); string query = "SELECT Id, Originator, Fault, DateTimeAdded FROM [Logging].[Log] WHERE Id_LogType = 1 ORDER By Id DESC"; using (SqlCommand command = new SqlCommand(query, connection)) { SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { DataObject.Log dataObject = new DataObject.Log(); dataObject.Id = int.Parse(reader.GetValue(0).ToString()); dataObject.Originator = reader.GetValue(1).ToString(); dataObject.Fault = reader.GetValue(2).ToString(); dataObject.DateAdded = Convert.ToDateTime(reader.GetValue(3).ToString()); list.Add(dataObject); } } } } return(list); }