示例#1
0
        public static void Insert(Empdemo obj)
        {
            Model_Emp_DBContainer model_Emp_DB = new Model_Emp_DBContainer();

            model_Emp_DB.Empdemoes.Add(obj);
            model_Emp_DB.SaveChanges();
        }
示例#2
0
        //Q2.Using model first approach generate database, and classes.
        //    [complete emp dept task] perform insert, delete, update
        static void Main(string[] args)
        {
            Print();

            // Creating Object
            Empdemo emp = new Empdemo {
                Name = "tshank", Salary = 45000, DeptdemoId = 2
            };

            //insert object as an entry into the database
            Insert(emp);

            //Updating the values(name and salary) of the employee in database using Id
            UpdateName(10, "Tushank");
            UpdateSalary(10, 48000);

            //Deleting the employee in database using Id
            Delete(7);

            Console.WriteLine("\nAfter Modification:");
            Print();

            //Adding new Department
            AddNewDept("FrontEnd");
            PrintDept();

            //Updating new Department
            UpdateDept(4, "Backend");
            PrintDept();

            //Delete(6);
            PrintDept();
        }
示例#3
0
        public static void Delete(int id)
        {
            Model_Emp_DBContainer model_Emp_DB = new Model_Emp_DBContainer();
            Empdemo todelete = model_Emp_DB.Empdemoes.Find(id);

            model_Emp_DB.Empdemoes.Remove(todelete);
            model_Emp_DB.SaveChanges();
        }
示例#4
0
        public static void UpdateSalary(int id, float salary)
        {
            Model_Emp_DBContainer model_Emp_DB = new Model_Emp_DBContainer();
            Empdemo update = model_Emp_DB.Empdemoes.Find(id);

            update.Salary = salary;
            model_Emp_DB.SaveChanges();
        }