private static LightValues ReadLightValues(IDataRecord reader) { int lightValue = reader.GetInt32(0); LightValues lightValues = new LightValues { Lightvalue = lightValue }; return(lightValues); }
public IList <LightValues> GetLightValue() { string selectStr = "select Lightvalue from Lightsensor"; using (SqlConnection databaseConnection = new SqlConnection(ConnectionString)) { databaseConnection.Open(); using (SqlCommand selectCommand = new SqlCommand(selectStr, databaseConnection)) { selectCommand.Parameters.AddWithValue("@selectStr", selectStr); using (SqlDataReader reader = selectCommand.ExecuteReader()) { List <LightValues> lightValueList = new List <LightValues>(); while (reader.Read()) { LightValues lightValues = ReadLightValues(reader); lightValueList.Add(lightValues); } return(lightValueList); } } } }