linq 获取数据库时间 或者执行其他带返回值的sql查询

来源:互联网 发布:ajax get传json 编辑:程序博客网 时间:2024/04/28 09:27

 using (LongXingDBDataContext db = new LongXingDBDataContext())
             {
                 DeviceInfo di;
                 di = new DeviceInfo();
                            
                 var a = db.ExecuteQuery<DateTime>("select  getdate()",new object[] {});               
                 di.CreateDate = a.First();


                 db.DeviceInfo.InsertOnSubmit(di);
                 db.SubmitChanges();
                 this.toolTip1.Show("保存完毕", this, ((Control)sender).Location, 2000);
             }