private void detach_Orders(Orders entity)
 {
     this.SendPropertyChanging();
     entity.Customers = null;
 }
 private void detach_Orders(Orders entity)
 {
     this.SendPropertyChanging();
     entity.Employees = null;
 }
 private void attach_Orders(Orders entity)
 {
     this.SendPropertyChanging();
     entity.Customers = this;
 }
 private void attach_Orders(Orders entity)
 {
     this.SendPropertyChanging();
     entity.Employees = this;
 }
 partial void DeleteOrders(Orders instance);
 partial void UpdateOrders(Orders instance);
 partial void InsertOrders(Orders instance);
Example #8
0
        private static void AddCusto()
        {
            Orders order1 = new Orders {
                CustomerID     = "AA85",
                EmployeeID     = 4,
                OrderDate      = DateTime.Now,
                RequiredDate   = DateTime.Now.AddDays(7),
                ShipVia        = 3,
                Freight        = new Decimal(24.66),
                ShipName       = "Lawn Wranglers",
                ShipAddress    = "1017 Maple Leaf Way",
                ShipCity       = "Ft. Worth",
                ShipRegion     = "TX",
                ShipPostalCode = "76104",
                ShipCountry    = "USA"
            };


            using (var data = new DataClassesMyNor2DataContext())
            {
                // Создание экземпляра сущностного объекта
                Customers cust = new Customers
                {
                    CustomerID   = "AA85",
                    CompanyName  = "ADONET",
                    ContactName  = "Niko",
                    ContactTitle = "Owner",
                    Address      = "1017 Maple Leaf",
                    City         = "Moscow",
                    Region       = "MC",
                    PostalCode   = "555555",
                    Country      = "Russia",
                    Phone        = "+7(000)123-4567",
                    Fax          = "None"
                                   //,
                                   //Orders = {
                                   //  new Orders {
                                   //    CustomerID = "AA85",
                                   //    EmployeeID = 4,
                                   //    OrderDate = DateTime.Now,
                                   //    RequiredDate = DateTime.Now.AddDays(7),
                                   //    ShipVia = 3,
                                   //    Freight = new Decimal(24.66),
                                   //    ShipName = "Lawn Wranglers",
                                   //    ShipAddress = "1017 Maple Leaf Way",
                                   //    ShipCity = "Ft. Worth",
                                   //    ShipRegion = "TX",
                                   //    ShipPostalCode = "76104",
                                   //    ShipCountry = "USA"
                                   //  },
                                   //}
                };

                data.Orders.InsertOnSubmit(order1);

                // 3. Добавление сущностного объекта в таблицу Customers
                data.Customers.InsertOnSubmit(cust);

                // 4. Вызов метода для записи в базу
                data.SubmitChanges();

                // Проверяем наличие вставленной записи
                Customers getcust = (from c in data.Customers
                                     where c.CustomerID == "AA85"
                                     select c).First <Customers>();

                Console.WriteLine("\n Новый заказчик {0} вставлен в базу данных",
                                  getcust == null ? "не" : "успешно");
            }
        }