예제 #1
0
        public static int GetProjectsCountByEmployee(string firstName, string lastName)
        {
            using (var softuniDbContext = new SoftUniEntities())
            {
                var count = softuniDbContext.usp_GetProjectsCountByEmployee(firstName, lastName).FirstOrDefault();
                if (count == null)
                {
                    throw new InvalidOperationException("Can't get projects count.");
                }

                return count.Value;
            }
        }
예제 #2
0
        public static void PerformConcurrentTasks()
        {
            using (var firstContext = new SoftUniEntities())
            {
                using (var secondContext = new SoftUniEntities())
                {
                    firstContext.Employees.Find(5).MiddleName = "Georgiev";
                    secondContext.Employees.Find(5).MiddleName = "Petrov";

                    firstContext.SaveChanges();
                    secondContext.SaveChanges();
                }
            }

            using (var context = new SoftUniEntities())
            {
                var middleName = context.Employees.Find(5).MiddleName;
                Console.WriteLine(middleName);
            }
        }