public static Employee FindByKey(object key)
 {
     using(var context = new SoftUniEntities())
     {
         return context.Employees.Find(key);
     }
 }
예제 #2
0
 public static Employee FindByKey(object key)
 {
     using (var context = new SoftUniEntities())
     {
         return(context.Employees.Find(key));
     }
 }
 public static void Add(Employee emp)
 {
     using (var context = new SoftUniEntities())
     {
         context.Employees.Add(emp);
         context.SaveChanges();
     }
 }
예제 #4
0
 public static void Add(Employee emp)
 {
     using (var context = new SoftUniEntities())
     {
         context.Employees.Add(emp);
         context.SaveChanges();
     }
 }
예제 #5
0
        static void Main()
        {
            var context = new SoftUniEntities();


            var employee = context.Employees.First();
            // I hardly even understand the problem, there are no deliverables specified, it kinda sucks and I'm not doing it
            // Here, read something about best practices when updating records http://stackoverflow.com/questions/15336248/entity-framework-5-updating-a-record
        }
        public static void Delete(Employee emp)
        {
            using (var context = new SoftUniEntities())
            {
                context.Employees.Attach(emp);
                context.Employees.Remove(emp);

                context.SaveChanges();
            }
        }
예제 #7
0
        public static void Delete(Employee emp)
        {
            using (var context = new SoftUniEntities())
            {
                context.Employees.Attach(emp);
                context.Employees.Remove(emp);

                context.SaveChanges();
            }
        }