Ejemplo n.º 1
0
        protected void RetrieveByPrimaryKey()
        {
            SensorModel firstRow       = Database.Table <SensorModel>().Take(1).First();
            var         sensorReading1 = Database.Get <SensorModel>(firstRow.ID);

            Console.WriteLine($"Sensor Reading 1: {sensorReading1.Value}");
        }
Ejemplo n.º 2
0
        protected void DeleteARow()
        {
            // pull the first record out of the table
            SensorModel reading = Database.Table <SensorModel>().Take(1).First();

            Console.WriteLine($"First record ID: {reading.ID}");
            Database.Delete <SensorModel>(reading.ID);
            Console.WriteLine($"Deleted the record");
            // get the first record again
            reading = Database.Table <SensorModel>().Take(1).First();
            Console.WriteLine($"new first record ID: {reading.ID}");
        }
Ejemplo n.º 3
0
        protected void UpdateData()
        {
            // pull the first record out of the table
            SensorModel reading = Database.Table <SensorModel>().Take(1).First();

            Console.WriteLine($"Found a record, ID: {reading.ID}");

            // change the value
            reading.Value = reading.Value * 2;

            // update the data
            Database.Update(reading);
        }