Пример #1
0
        private static void Populate(EpmCustomObjectContext context)
        {
            AstoriaUnitTests.ObjectContextStubs.Types.EpmCustomer[] customers = new AstoriaUnitTests.ObjectContextStubs.Types.EpmCustomer[3];
            for (int i = 0; i < customers.Length; i++)
            {
                AstoriaUnitTests.ObjectContextStubs.Types.EpmCustomer customer = (i % 2 == 0) ? new AstoriaUnitTests.ObjectContextStubs.Types.EpmCustomer() : new AstoriaUnitTests.ObjectContextStubs.Types.EpmCustomerWithBirthday();
                customer.ID   = i;
                customer.Name = "Customer " + i.ToString();

                if (customer.GetType() == typeof(AstoriaUnitTests.ObjectContextStubs.Types.EpmCustomerWithBirthday))
                {
                    ((AstoriaUnitTests.ObjectContextStubs.Types.EpmCustomerWithBirthday)customer).Birthday = DateTime.Now;
                }

                AstoriaUnitTests.ObjectContextStubs.Types.EpmOrder o1 = new AstoriaUnitTests.ObjectContextStubs.Types.EpmOrder();
                o1.ID           = i;
                o1.DollarAmount = 20.1;

                AstoriaUnitTests.ObjectContextStubs.Types.EpmOrder o2 = new AstoriaUnitTests.ObjectContextStubs.Types.EpmOrder();
                o2.ID           = i + 100;
                o2.DollarAmount = 30.2;

                customer.Orders.Add(o1);
                customer.Orders.Add(o2);
                context.AddToEpmCustomers(customer);
                customers[i] = customer;
            }

            AstoriaUnitTests.ObjectContextStubs.Types.EpmProduct p = new AstoriaUnitTests.ObjectContextStubs.Types.EpmProduct();
            p.ProductID    = 1;
            p.ProductName  = "PotatoChips";
            p.Discontinued = false;
            context.AddToEpmProducts(p);

            context.SaveChanges();
        }
Пример #2
0
        private static void Populate(EpmCustomObjectContext context)
        {
            AstoriaUnitTests.ObjectContextStubs.Types.EpmCustomer[] customers = new AstoriaUnitTests.ObjectContextStubs.Types.EpmCustomer[3];
            for (int i = 0; i < customers.Length; i++)
            {
                AstoriaUnitTests.ObjectContextStubs.Types.EpmCustomer customer = (i % 2 == 0) ? new AstoriaUnitTests.ObjectContextStubs.Types.EpmCustomer() : new AstoriaUnitTests.ObjectContextStubs.Types.EpmCustomerWithBirthday();
                customer.ID = i;
                customer.Name = "Customer " + i.ToString();
                
                if (customer.GetType() == typeof(AstoriaUnitTests.ObjectContextStubs.Types.EpmCustomerWithBirthday))
                {
                    ((AstoriaUnitTests.ObjectContextStubs.Types.EpmCustomerWithBirthday)customer).Birthday = DateTime.Now;
                }

                AstoriaUnitTests.ObjectContextStubs.Types.EpmOrder o1 = new AstoriaUnitTests.ObjectContextStubs.Types.EpmOrder();
                o1.ID = i;
                o1.DollarAmount = 20.1;

                AstoriaUnitTests.ObjectContextStubs.Types.EpmOrder o2 = new AstoriaUnitTests.ObjectContextStubs.Types.EpmOrder();
                o2.ID = i + 100;
                o2.DollarAmount = 30.2;

                customer.Orders.Add(o1);
                customer.Orders.Add(o2);
                context.AddToEpmCustomers(customer);
                customers[i] = customer;
            }

            AstoriaUnitTests.ObjectContextStubs.Types.EpmProduct p = new AstoriaUnitTests.ObjectContextStubs.Types.EpmProduct();
            p.ProductID = 1;
            p.ProductName = "PotatoChips";
            p.Discontinued = false;
            context.AddToEpmProducts(p);

            context.SaveChanges();
        }