Example #1
0
        static void InsertOrder(
        string shipName, string shipAddress,
        string shipCity, string shipRegionm,
        string shipPostalCode, string shipCountry,
        string customerID = null, int? employeeID = null,
        DateTime? orderDate = null, DateTime? requiredDate = null,
        DateTime? shippedDate = null, int? shipVia = null,
        decimal? freight = null)
        {
            using (NORTHWNDEntities context = new NORTHWNDEntities())
            {
                Order newOrder = new Order
                {
                    ShipAddress = shipAddress,
                    ShipCity = shipCity,
                    ShipCountry = shipCountry,
                    ShipName = shipName,
                    ShippedDate = shippedDate,
                    ShipPostalCode = shipPostalCode,
                    ShipRegion = shipRegionm,
                    ShipVia = shipVia,
                    EmployeeID = employeeID,
                    OrderDate = orderDate,
                    RequiredDate = requiredDate,
                    Freight = freight,
                    CustomerID = customerID
                };

                context.Orders.Add(newOrder);

                context.SaveChanges();

                Console.WriteLine("Row is inserted.");
            }
        }
        static void Main()
        {
            using (NORTHWNDEntities northwindEntities1 = new NORTHWNDEntities())
            {
                using (NORTHWNDEntities northwindEntities2 = new NORTHWNDEntities())
                {
                    Customer editedCustomer1 = northwindEntities1.Customers.Find("WELLI");
                    editedCustomer1.Region = "SP1";

                    Customer editedCustomer2 = northwindEntities2.Customers.Find("WELLI");
                    editedCustomer2.Region = "SP2";

                    northwindEntities1.SaveChanges();
                    northwindEntities2.SaveChanges();

                }
            }
        }