static public void Delete(System.Int32 orderID)
        {
            var obj = new Order();

            obj.OrderID = orderID;
            obj.AcceptChanges();
            obj.MarkAsDeleted();
            obj.Save();
        }
        static public void Delete(System.Int32 orderID, esSqlAccessType sqlAccessType)
        {
            var obj = new Order();

            obj.OrderID = orderID;
            obj.AcceptChanges();
            obj.MarkAsDeleted();
            obj.Save(sqlAccessType);
        }
        public void TestMultiDeleteEntity()
        {
            int empKey = -1;
            int ordKey = -1;
            CustomerGroup custGroup = new CustomerGroup();
            custGroup.es.Connection.Name = "ForeignKeyTest";
            EmployeeCollection empColl = new EmployeeCollection();
            empColl.es.Connection.Name = "ForeignKeyTest";
            Employee emp = new Employee();
            emp.es.Connection.Name = "ForeignKeyTest";
            Employee testEmp = new Employee();
            testEmp.es.Connection.Name = "ForeignKeyTest";
            Customer cust = new Customer();
            cust.es.Connection.Name = "ForeignKeyTest";
            Order ord = new Order();
            ord.es.Connection.Name = "ForeignKeyTest";

            try
            {
                using (esTransactionScope scope = new esTransactionScope())
                {
                    // Setup
                    custGroup.GroupID = "YYYYY";
                    custGroup.GroupName = "Test";
                    custGroup.Save();

                    emp = empColl.AddNew();
                    emp.LastName = "LastName";
                    emp.FirstName = "FirstName";

                    cust = emp.CustomerCollectionByStaffAssigned.AddNew();
                    cust.CustomerID = "YYYYY";
                    cust.CustomerSub = "YYY";
                    cust.CustomerName = "Test";
                    cust.str().DateAdded = "2007-01-01 00:00:00";
                    cust.Active = true;
                    cust.Manager = 1;

                    ord = emp.OrderCollectionByEmployeeID.AddNew();
                    ord.CustID = "YYYYY";
                    ord.CustSub = "YYY";
                    ord.str().OrderDate = "2007-01-01";

                    empColl.Save();
                    empKey = emp.EmployeeID.Value;
                    ordKey = ord.OrderID.Value;

                    Assert.AreEqual(1, emp.CustomerCollectionByStaffAssigned.Count);
                    Assert.AreEqual(1, emp.OrderCollectionByEmployeeID.Count);
                    Assert.AreEqual(emp.EmployeeID.Value, cust.StaffAssigned.Value);
                    Assert.AreEqual(emp.EmployeeID.Value, ord.EmployeeID.Value);

                    // Test
                    testEmp.LoadByPrimaryKey(empKey);
                    testEmp.OrderCollectionByEmployeeID.MarkAllAsDeleted();
                    testEmp.CustomerCollectionByStaffAssigned.MarkAllAsDeleted();
                    testEmp.MarkAsDeleted();
                    testEmp.Save();

                    emp = new Employee();
                    emp.es.Connection.Name = "ForeignKeyTest";
                    Assert.IsFalse(emp.LoadByPrimaryKey(empKey));

                    ord = new Order();
                    ord.es.Connection.Name = "ForeignKeyTest";
                    Assert.IsFalse(ord.LoadByPrimaryKey(ordKey));

                    cust = new Customer();
                    cust.es.Connection.Name = "ForeignKeyTest";
                    Assert.IsFalse(cust.LoadByPrimaryKey("YYYYY", "YYY"));
                }
            }
            finally
            {
                // Clean up
                ord = new Order();
                ord.es.Connection.Name = "ForeignKeyTest";
                if (ord.LoadByPrimaryKey(ordKey))
                {
                    ord.MarkAsDeleted();
                    ord.Save();
                }

                cust = new Customer();
                cust.es.Connection.Name = "ForeignKeyTest";
                if (cust.LoadByPrimaryKey("YYYYY", "YYY"))
                {
                    cust.MarkAsDeleted();
                    cust.Save();
                }

                emp = new Employee();
                emp.es.Connection.Name = "ForeignKeyTest";
                if (emp.LoadByPrimaryKey(empKey))
                {
                    emp.MarkAsDeleted();
                    emp.Save();
                }

                custGroup = new CustomerGroup();
                custGroup.es.Connection.Name = "ForeignKeyTest";

                if (custGroup.LoadByPrimaryKey("YYYYY"))
                {
                    custGroup.MarkAsDeleted();
                    custGroup.Save();
                }
            }
        }