public List <OrderNotificationLogEntry> GetForOrder(string OrderThumbprint) { List <OrderNotificationLogEntry> returnMe = new List <OrderNotificationLogEntry>(); using (SqlConnection connection = new SqlConnection(_dbConnection.ConnectionString)) { using (SqlCommand sqlCommand = new SqlCommand { Connection = connection, CommandType = CommandType.Text, CommandText = "SELECT * FROM OrderNotifications WHERE OrderThumbprint=@ORDERID" }) { sqlCommand.Parameters.AddWithValue("ORDERID", OrderThumbprint); sqlCommand.Connection.Open(); SqlDataReader dbDataReader = sqlCommand.ExecuteReader(); if (dbDataReader.HasRows) { while (dbDataReader.Read()) { OrderNotificationLogEntry notification = dataReaderToObject(dbDataReader); if (notification != null) { returnMe.Add(notification); } } } sqlCommand.Connection.Close(); } } return(returnMe); }
public List <OrderNotificationLogEntry> GetRecent(int count) { List <OrderNotificationLogEntry> returnMe = new List <OrderNotificationLogEntry>(); using (SqlConnection connection = new SqlConnection(_dbConnection.ConnectionString)) { using (SqlCommand sqlCommand = new SqlCommand { Connection = connection, CommandType = CommandType.Text, CommandText = "SELECT TOP " + count + " * FROM OrderNotifications ORDER BY NotificationDate DESC" }) { sqlCommand.Connection.Open(); SqlDataReader dbDataReader = sqlCommand.ExecuteReader(); if (dbDataReader.HasRows) { while (dbDataReader.Read()) { OrderNotificationLogEntry notification = dataReaderToObject(dbDataReader); if (notification != null) { returnMe.Add(notification); } } } sqlCommand.Connection.Close(); } } return(returnMe); }