码迷,mamicode.com
首页 > 其他好文 > 详细

EF简单的添加修改删除基本语法

时间:2016-11-07 14:24:16      阅读:238      评论:0      收藏:0      [点我收藏+]

标签:default   ges   select   move   first   efault   from   删除   where   

      using ( androidhiveEntities db = new androidhiveEntities() )
                {

                    #region 添加
                    //aa a = new aa() { endDate =DateTime.Now,name="张三",doccode="ddoccode ",startDate=DateTime.Now };
                    //db.aa.Add(a);
                    //db.SaveChanges();
                    #endregion

                    #region 修改

                    //修改
                    var a1 = (from u in db.aa where u.id == 25 select u).FirstOrDefault();
                    a1.name = "李晓四";
                    var a = (from u in db.aa where u.id == 27 select u).FirstOrDefault();
                    a.name  = "张晓三";
                    db.SaveChanges();
                    #endregion

                    #region 删除
                    //var a = (from u in db.aa where u.id == 26 select u).First();
                    //db.aa.Remove(a);

                    //db.SaveChanges();
                    #endregion
                }

EF简单的添加修改删除基本语法

标签:default   ges   select   move   first   efault   from   删除   where   

原文地址:http://www.cnblogs.com/cl1006/p/6038659.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!