/// <summary>
 /// Create a new CustomerBlob object.
 /// </summary>
 /// <param name="ID">Initial value of ID.</param>
 /// <param name="address">Initial value of Address.</param>
 public static CustomerBlob CreateCustomerBlob(int ID, Address address)
 {
     CustomerBlob customer = new CustomerBlob();
     customer.ID = ID;
     customer.Address = global::System.Data.Objects.DataClasses.StructuralObject.VerifyComplexObjectIsNotNull(address, "Address");
     return customer;
 }
예제 #2
0
        /// <summary>
        /// Create a new CustomerBlob object.
        /// </summary>
        /// <param name="ID">Initial value of ID.</param>
        /// <param name="address">Initial value of Address.</param>
        public static CustomerBlob CreateCustomerBlob(int ID, Address address)
        {
            CustomerBlob customer = new CustomerBlob();

            customer.ID      = ID;
            customer.Address = global::System.Data.Objects.DataClasses.StructuralObject.VerifyComplexObjectIsNotNull(address, "Address");
            return(customer);
        }
예제 #3
0
        private static void Populate(CustomObjectContext context)
        {
            Customer[] customers = new Customer[3];
            for (int i = 0; i < customers.Length; i++)
            {
                Customer customer = (i % 2 == 0) ? new Customer() : new CustomerWithBirthday();
                customer.ID            = i;
                customer.Name          = "Customer " + i.ToString();
                customer.Concurrency   = i.ToString();
                customer.EditTimeStamp = new byte[] { 2, 10 };
                customer.Address       = new Address()
                {
                    StreetAddress = "Line1",
                    City          = "Redmond",
                    State         = "WA",
                    PostalCode    = "98052"
                };

                if (customer.GetType() == typeof(CustomerWithBirthday))
                {
                    ((CustomerWithBirthday)customer).Birthday = DateTime.Now;
                }

                if (i > 0)
                {
                    customer.BestFriend = customers[i - 1];
                }

                Order o1 = new Order();
                o1.ID           = i;
                o1.DollarAmount = 20.1;

                Order o2 = new Order();
                o2.ID           = i + 100;
                o2.DollarAmount = 30.2;

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

            CustomerBlob[] customerBlobs = new CustomerBlob[3];
            for (int i = 0; i < customerBlobs.Length; i++)
            {
                CustomerBlob customer = (i % 2 == 0) ? new CustomerBlob() : new CustomerBlobWithBirthday();
                customer.ID          = i;
                customer.Name        = "CustomerBlob " + i.ToString();
                customer.Concurrency = i.ToString();

                if (customer.GetType() == typeof(CustomerBlobWithBirthday))
                {
                    ((CustomerBlobWithBirthday)customer).Birthday = DateTime.Now;
                }

                context.AddToCustomerBlobs(customer);
                customerBlobs[i] = customer;
            }

            if (CustomersCustomizer != null)
            {
                CustomersCustomizer(customers, context);
            }

            context.SaveChanges();
        }