Example #1
0
        public void Update(AssociateSalary entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            _associateSalaryRepository.Update(entity);
        }
Example #2
0
        private static async Task LoadData()
        {
            using (var context = new AssociateEntities())
            {
                // 添加测试数据
                Console.WriteLine("Adding Test Data");
                Console.WriteLine("=========\n");

                var assoc1 = new Associate {
                    Name = "Janis Roberts"
                };
                var assoc2 = new Associate {
                    Name = "Kevin Hodges"
                };
                var assoc3 = new Associate {
                    Name = "Bill Jordan"
                };

                var salary1 = new AssociateSalary
                {
                    Salary     = 39500M,
                    SalaryDate = DateTime.Parse("8/4/14")
                };
                var salary2 = new AssociateSalary
                {
                    Salary     = 41900M,
                    SalaryDate = DateTime.Parse("2/5/15")
                };
                var salary3 = new AssociateSalary
                {
                    Salary     = 33500M,
                    SalaryDate = DateTime.Parse("10/08/13")
                };

                assoc1.AssociateSalaries.Add(salary1);
                assoc2.AssociateSalaries.Add(salary2);
                assoc3.AssociateSalaries.Add(salary3);

                context.Associates.Add(assoc1);
                context.Associates.Add(assoc2);
                context.Associates.Add(assoc3);

                //异步保存
                await context.SaveChangesAsync();

                await Task.Delay(5000);
            }
        }
Example #3
0
        private static async Task LoadData()
        {
            using (var context = new EFRecipesEntities())
            {
                // add new test data
                Console.WriteLine("Adding Test Data");
                Console.WriteLine("=========\n");
                var assoc1 = new Associate {
                    Name = "Janis Roberts"
                };
                var assoc2 = new Associate {
                    Name = "Kevin Hodges"
                };
                var assoc3 = new Associate {
                    Name = "Bill Jordan"
                };
                var salary1 = new AssociateSalary
                {
                    Salary     = 39500M,
                    SalaryDate = DateTime.Parse("8/4/09")
                };
                var salary2 = new AssociateSalary
                {
                    Salary     = 41900M,
                    SalaryDate = DateTime.Parse("2/5/10")
                };
                var salary3 = new AssociateSalary
                {
                    Salary     = 33500M,
                    SalaryDate = DateTime.Parse("10/08/09")
                };
                assoc1.AssociateSalaries.Add(salary1);
                assoc2.AssociateSalaries.Add(salary2);
                assoc3.AssociateSalaries.Add(salary3);
                context.Associates.Add(assoc1);
                context.Associates.Add(assoc2);
                context.Associates.Add(assoc3);
                // update datastore asynchronoulsy
                await context.SaveChangesAsync();

                await Task.Delay(5000);
            }
        }