示例#1
0
        public static void Initialize(TnContext context)
        {
            if (context.EmployeesBase.Any())
            {
                return;
            }
            for (var i = 1; i < 99; i++)
            {
                var     random  = new Random();
                decimal randNum = random.Next(100);
                if (randNum < 50)
                {
                    context.EmployeesOnSalary.Add(
                        new EmployeeOnSalary
                    {
                        Name          = "Иванов Иван" + i.ToString().PadLeft(3, '0'),
                        MonthlySalary = 100000 * (1 + randNum / 100)
                    }
                        );
                }
                else
                {
                    context.EmployeesOnRate.Add(
                        new EmployeeOnRate
                    {
                        Name       = "Иванов Иван" + i.ToString().PadLeft(3, '0'),
                        HourlyRate = 1000 * (1 + randNum / 100)
                    }
                        );
                }
            }

            context.SaveChanges();
        }
示例#2
0
 public EmployeeRepo(TnContext context)
 {
     _context = context;
 }