Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Deleting child entities inside parent / child relationship
Message
From
30/06/2008 17:26:42
 
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Deleting child entities inside parent / child relationship
Miscellaneous
Thread ID:
01327749
Message ID:
01327749
Views:
54
Hi,

I am having problems figuring out deleting entities from a child list with parent. I have tried this using the Order - Order Details objects from the Jump Start.

Here is some test code.
   [Test]
        public void TestOrderDetails()
        {
            // create a new order header
            Order theOrder = new Order();

            OrderDetail theDetails = new OrderDetail();

            theOrder.RegisterChildBizObj(theDetails);

            theOrder.Entity = theOrder.GetOrderByOrderID(10251);

            Console.Out.WriteLine("Details for Order: " + theOrder.Entity.OrderID.ToString() + " - " + theOrder.Entity.OrderDate.ToString());

            foreach (OrderDetailEntity detail in theDetails.EntityList)
            {
                Console.Out.WriteLine(detail.ProductID.ToString());
            }

            // delete the first detail line from the details entity list.

            theDetails.EntityList.RemoveAt(0);

            mmSaveDataResult saveResult = theOrder.SaveEntity();

            if(saveResult == mmSaveDataResult.RulesBroken)
            {
                Console.Error.WriteLine(theOrder.Rules.GetAllBrokenRules());
            }

            Assert.That(saveResult != mmSaveDataResult.RulesBroken,"Error saving order!");

            // load the the details back from the server to see if deleted

            theOrder = new Order();

            theDetails = new OrderDetail();

            theOrder.RegisterChildBizObj(theDetails);

            theOrder.Entity = theOrder.GetOrderByOrderID(10251);

            Console.Out.WriteLine("Details for Order: " + theOrder.Entity.OrderID.ToString() + " - " + theOrder.Entity.OrderDate.ToString());

            foreach (OrderDetailEntity detail in theDetails.EntityList)
            {
                Console.Out.WriteLine(detail.ProductID.ToString());
            }
        }

    }
The code executes without errors, but the row deleted from the entity list is not deleted from the table.

What am I missing?

Thanks

Tim Holgerson
Next
Reply
Map
View

Click here to load this message in the networking platform