public static void DeleteEmployee() { EmployeeEFDBEntities context = new EmployeeEFDBEntities(); var employees = context.Employees; var employee = new Employee { EmpID = 7 }; employees.Attach(employee); employees.Remove(employee); context.SaveChanges(); }
public static void ModifyEmp() { EmployeeEFDBEntities Context = new EmployeeEFDBEntities(); var Emp21 = Context.Employees; var emplist = from Employee in Emp21 orderby Employee.EmpID select Emp21; foreach (var Employee in Emp21) { if (Employee.EmpID == 1) Employee.Name = "Mathew"; } Context.SaveChanges(); }
public static void ModifyEmployee() { EmployeeEFDBEntities context = new EmployeeEFDBEntities(); var employees = context.Employees; var empList = from emp in employees orderby emp.Salary select emp; foreach (var emp in empList) { if (emp.EmpID == 1) { emp.Name = "sreeharibabu"; } } context.SaveChanges(); }
public static void modifyemployee() { EmployeeEFDBEntities context = new EmployeeEFDBEntities(); var employees = context.Employees; var emplist = from emp in employees orderby emp.Salary select emp; foreach (var emp in employees) { if (emp.EmpID == 1) { emp.Name = "johny"; } } context.SaveChanges(); }
static void Main(string[] args) { LinqToEntity(); ModifyEmployee(); DeleteEmployee(); EmployeeEFDBEntities context = new EmployeeEFDBEntities(); //var employee = new Employee() //{ // EmpID = 1, // Name = "Andrew Trolesan", // Salary = 35000, // SSN = 23456, // DepID = 3 //}; //context.Employees.Add(employee); //context.SaveChanges(); //var employee2 = new Employee() //{ // EmpID = 2, // Name = "Jeffery Richer", // Salary = 35000, // SSN = 34567, // DepID = 3 //}; //context.Employees.Add(employee2); //var employee3 = new Employee() //{ // EmpID = 3, // Name = "Andrew Trolesan", // Salary = 39000, // SSN = 34567, // DepID = 3 //}; //context.Employees.Add(employee3); context.SaveChanges(); }
static void Main(string[] args) { LinqToEntity(); //ModifyEmployee(); //DeleteEmployee(); EmployeeEFDBEntities context = new EmployeeEFDBEntities(); //var employee = new Employee() //{ // EmpID = 6, // Name = "Andrew Trolesan", // Salary = 35000, // SSN = 2345678, // DepID = 3 //}; //context.Employees.Add(employee); //context.SaveChanges(); //var employee2 = new Employee() //{ // EmpID = 8, // Name = "hari chandana", // Salary = 3000, // SSN = 2345, // DepID = 4 //}; // context.Employees.Add(employee2); //var employee3 = new Employee() //{ // EmpID = 2, // Name = "chandana", // Salary = 13000, // SSN = 234345, // DepID = 6 //}; //context.Employees.Add(employee3); context.SaveChanges(); }