vs2013 linq to mysql

安装文件

1.下载安装文件

2.创建项目

3.创建mysql数据连接

4.新建ADO.NET数据模型

项目实现代码

 using (WorkerContainer db = new WorkerContainer()){
                IQueryable<workers_info> linq = from c in db.workers_info select c;
                List<workers_info> list = linq.ToList();
            }
            using (WorkerContainer db = new WorkerContainer()){
                var info = db.workers_info.SingleOrDefault<workers_info>(s => s.id == 2);
                info.email = "xxxxxx@126.com";
           db.SaveChanges(); }

 

  using (WorkerContainer db = new WorkerContainer()){
                workers_info infoModel = new workers_info();
                infoModel.email = "22222222";

                infoModel.salary = 3;
                infoModel.workername = "zhaoiyue";
                infoModel.EmployedDates = DateTime.Now;
                infoModel.department = "12312";

                db.workers_info.Add(infoModel);
                db.SaveChanges();
            }

 

posted @ 2016-07-26 15:40  枫之戊  阅读(1064)  评论(0编辑  收藏  举报