Exemple #1
0
        public IList <Measurements> GetAllData()
        {
            const string selectAllSensorData = "SELECT* FROM dbo.Measurements order by Id";

            using (SqlConnection databaseConnection = new SqlConnection(connStr))
            {
                databaseConnection.Open();
                using (SqlCommand selectCommand = new SqlCommand(selectAllSensorData, databaseConnection))
                {
                    using (SqlDataReader reader = selectCommand.ExecuteReader())
                    {
                        List <Measurements> sensorDataList = new List <Measurements>();
                        while (reader.Read())
                        {
                            Measurements measurement = ReadSensorData(reader);
                            sensorDataList.Add(measurement);
                        }
                        return(sensorDataList);
                    }
                }
            }
        }