Exemplo n.º 1
0
 private void BtnAdd_Click(object sender, EventArgs e)
 {
     using (var db = new CodeFirstModel())
     {
         var emp = new Employee {
             EmpName = "Srini 11", Department = "Science"
         };
         db.Employees.Add(emp);
         db.SaveChanges();
     }
 }
Exemplo n.º 2
0
        private void BtnGet_Click(object sender, EventArgs e)
        {
            using (var db = new CodeFirstModel())
            {
                var emp = (from objEmp in db.Employees
                           select objEmp).ToList <Employee>();

                foreach (Employee getEmp in emp)
                {
                    MessageBox.Show(getEmp.EmpName);
                }
            }
        }