示例#1
0
        void print_data()
        {
            Room_tempEntities temp_obj  = new Room_tempEntities();
            temp_dtls         room_temp = new temp_dtls();
            var filteredResult          = from s in temp_obj.temp_dtls
                                          where s.Temprature > max
                                          select s;

            foreach (var item in filteredResult)
            {
                Console.WriteLine("when temprature was increased");
                Console.WriteLine(item.Temprature);
                Console.WriteLine(item.currnt_time);
            }
            var filteredResult2 = from s in temp_obj.temp_dtls
                                  where s.Temprature < min
                                  select s;

            foreach (var item in filteredResult2)
            {
                Console.WriteLine("when temprature was decreased");
                Console.WriteLine(item.Temprature);
                Console.WriteLine(item.currnt_time);
            }
        }
示例#2
0
 void insert(int temp)
 {
     using (Room_tempEntities temp_obj = new Room_tempEntities())
     {
         temp_dtls room_temp = new temp_dtls
         {
             Temprature  = temp,
             currnt_time = DateTime.Now,
         };
         temp_obj.temp_dtls.Add(room_temp);
         temp_obj.SaveChanges();
     }
 }