public OrderForm(Order order, ClientTransaction transaction)
        {
            InitializeComponent();
            _transaction = transaction;

            // Create a proxy for the order that automatically opens the transaction scope
            // each time a value is assigned to a property.
            var tranOrder = _transaction.ScopeDataContext(order);

            // Bind text boxes to the properties of the proxy object.
            BindTextBox(textBoxID, tranOrder, "OrderID");
            BindTextBox(textBoxFreight, tranOrder, "Freight");
            BindTextBox(textBoxOrderDate, tranOrder, "OrderDate");
            BindTextBox(textBoxShipName, tranOrder, "ShipName");
            BindTextBox(textBoxShipCity, tranOrder, "ShipCity");

            // Define a live view of order details.
            var orderDetailsView = from od in order.Order_Details.AsLive()
                                   select new OrderDetailsInfo
            {
                OrderID   = od.OrderID,
                ProductID = od.ProductID,
                UnitPrice = od.UnitPrice,
                Discount  = od.Discount,
                Quantity  = od.Quantity
            };

            // All changes in this view are made in the transaction scope.
            orderDetailsView.SetTransaction(_transaction);
            orderDetailsGrid.DataSource = orderDetailsView;
        }
Exemplo n.º 2
0
        public OrderWindow(Order order, ClientTransaction transaction)
        {
            InitializeComponent();
            _transaction = transaction;

            // Create a proxy for the order that automatically opens the transaction scope
            // each time a value is assigned to a property; and use it for data binding.
            DataContext = transaction.ScopeDataContext(order);

            // Define a live view of order details.
            var orderDetailsView = from od in order.Order_Details.AsLive()
                                   select new OrderDetailsInfo
            {
                OrderID   = od.OrderID,
                ProductID = od.ProductID,
                UnitPrice = od.UnitPrice,
                Discount  = od.Discount,
                Quantity  = od.Quantity
            };

            // All changes in this view are made in the transaction scope.
            orderDetailsView.SetTransaction(_transaction);
            orderDetailsGrid.ItemsSource = orderDetailsView;
        }