private void UpdateInventory(DependentTransaction dt, SalesOrderDetail salesDetail)
        {
            try
            {
                using (AdventureWorksDataContext dc = new AdventureWorksDataContext())

                {
                    using (TransactionScope scope = (dt != null ?new TransactionScope(dt) :new TransactionScope(TransactionScopeOption.Suppress)))
                    {
                        var inventoryRow =
                                    (from pi in dc.ProductInventories
                                    where pi.ProductID == salesDetail.ProductID
                                    && pi.LocationID == 7 //finished goods storage
                                    select pi).SingleOrDefault();
                        if (inventoryRow != null)
                        {
                            inventoryRow.Quantity -= salesDetail.OrderQty;
                            inventoryRow.ModifiedDate = DateTime.Now;
                            Console.WriteLine(
                            "Product {0}: Reduced by {1}",
                            inventoryRow.ProductID, salesDetail.OrderQty);
                            dc.SubmitChanges();
                        }
                        scope.Complete();


                    }
                }
            }
                
            catch (Exception)
            {
                
                throw;
            }
            finally
            {
                //the ambient transaction will block on complete
                if (dt != null)
                {
                    dt.Complete();
                    dt.Dispose();
                }

            }
        }
        // If your activity returns a value, derive from CodeActivity<TResult>
        // and return the value from the Execute method.
        protected override void Execute(CodeActivityContext context)
        {
            SalesOrderDetail salesDetail = SalesDetail.Get(context);
            using (AdventureWorksDataContext dc = new AdventureWorksDataContext())
            {
                var historyRow = new TransactionHistory();
                historyRow.ProductID = salesDetail.ProductID;
                historyRow.ModifiedDate = DateTime.Now;
                historyRow.Quantity = salesDetail.OrderQty;
                historyRow.TransactionDate = salesDetail.ModifiedDate;
                historyRow.TransactionType = 'S';
                historyRow.ReferenceOrderID = salesDetail.SalesOrderID;
                historyRow.ReferenceOrderLineID = salesDetail.SalesOrderDetailID;
                dc.TransactionHistories.InsertOnSubmit(historyRow);
                dc.SubmitChanges();
                Console.WriteLine("Product {0}: Added history for Qty of {1} ",salesDetail.ProductID, salesDetail.OrderQty);
            }

        }