Example #1
0
        public void createdata(Employee employee)
        {
            var context = new EmpContext();

            context.Employees.Add(employee);
            context.SaveChanges();
        }
Example #2
0
        public List <Employee> Getdata()
        {
            var context    = new EmpContext();
            var EmpDetails = context.Employees.ToList();


            return(EmpDetails);
        }
Example #3
0
        public void DeleteData(int id)
        {
            var context = new EmpContext();

            var entity = context.Employees.FirstOrDefault(s => s.EmployeeId == id);


            if (entity != null)
            {
                context.Employees.Remove(entity);

                context.SaveChanges();
            }
        }
Example #4
0
        public void UpdateData(int id)
        {
            var context = new EmpContext();

            var entity = context.Employees.FirstOrDefault(s => s.EmployeeId == id);


            if (entity != null)
            {
                entity.EmployeeName = "Neha";

                context.Employees.Update(entity);


                context.SaveChanges();
            }
        }