我试图在文本框中显示结果 linq 查询显示。我在 SensorDataPackages 表中有 OID、readTime、DeviceID、a_TankLevel1、a_TankLevel2。我想在这样的查询返回后在文本框中显示某些字段的值
Textbox1 = a_TankLevel1;
Textbox2 = a_TankLevel2;
等等。
我得到“SensorData 不为空”。查询正在工作。
//我创建了新的模型数据集
private string istDeviceID = "";
MyWebApplication.MyClasses.ModelDataContext MyNewModel= new MyWebApplication.MyClasses.ModelDataContext();
this.istDeviceID = ComboBox1.SelectedItem.GetValue("DeviceID").ToString();
DateTime SensorDateNow= DateTime.Now;
DateTime SensorDate= DateTime.Now.AddDays(-7);
var SensorData = (from Sensor in MyNewModel.SensorDataPackages
where Sensor.DeviceID == int.Parse(istDeviceID)
where Sensor.readTime.Date >= SensorDateNow.Date
where Sensor.readTime.Date <= SensorDate.Date
select Sensor).ToList();
if (SensorData.Count > 0)
{
MessageBox.Show("SensorData is not empty");
textbox1.text = SensorData.?????? // I need help here !!!
}
else
{
MessageBox.Show("SensorData is empty");
}