Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Deleting child entities inside parent / child relationship
Message
De
30/06/2008 17:26:42
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Deleting child entities inside parent / child relationship
Divers
Thread ID:
01327749
Message ID:
01327749
Vues:
55
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform