示例#1
0
        public void Create(Department dpt)
        {
            using (var ctx = new LYLQEntities())
            {
                ctx.Departments.Add(dpt);

                ctx.SaveChanges();
            }
        }
示例#2
0
        public void Update(Department dpt)
        {
            using (var ctx = new LYLQEntities())
            {
                var dbDpts = from dbDpt in ctx.Departments
                             where dbDpt.Code == dpt.Code
                             select dbDpt;

                var dbModelDpt = dbDpts.First();
                dbModelDpt.Name = dpt.Name;
                dbModelDpt.UpdatedBy = dpt.UpdatedBy;
                dbModelDpt.UpdatedDate = DateTime.Now;

                ctx.SaveChanges();
            }
        }