예제 #1
0
        public static async Task AddCourses()
        {
            using (var context = new SimpleContext())
            {
                Console.WriteLine("Adding new courses");
                var lineManager = context.LineManagers.FirstOrDefault();
                var courses = new List<Course>
                {
                    new Course {CourseName="EF in advanced", LineManager = lineManager},
                    new Course {CourseName="Azure services", LineManager = lineManager},
                };

                context.Courses.AddRange(courses);

                var developer = context.Developers.FirstOrDefault();

                var developerCourse = new List<DeveloperCourse>
                {
                    new DeveloperCourse {Developer = developer, Course = courses[0] },
                    new DeveloperCourse {Developer = developer, Course = courses[1] },
                };
                context.DeveloperCourses.AddRange(developerCourse);

                await context.SaveChangesAsync();
                Console.WriteLine("Done");
            }
        }
예제 #2
0
 public static async Task AddLineManager()
 {
     using (var context = new SimpleContext())
     {
         Console.WriteLine("Adding new line manager");
         var lineManager = new LineManager { FullName = "Phuong Le" };
         context.LineManagers.Add(lineManager);
         await context.SaveChangesAsync();
         Console.WriteLine("Done");
     }
 }
예제 #3
0
 public static async Task AddDeveloper()
 {
     using (var context = new SimpleContext())
     {
         Console.WriteLine("Adding new developer");
         var lineManager = context.LineManagers.FirstOrDefault();
         var developer = new Developer { FullName = "Phi Huynh", LineManager = lineManager };
         context.Developers.Add(developer);
         await context.SaveChangesAsync();
         Console.WriteLine("Done");
     }
 }
예제 #4
0
 public static async Task UpdateDeveloper(string name, int milliseconds)
 {
     try {
         using (var context = new SimpleContext())
         {
             var developer = context.Developers.Where(d => d.Id.Equals(1)).Single();
             developer.FullName = name;
             Thread.Sleep(milliseconds);
             await context.SaveChangesAsync();
             Console.WriteLine("Done");
         }
     }
     catch(Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }