Solved

Delete multiple rows in Entity Framework

Posted on 2014-01-23
1
553 Views
Last Modified: 2014-01-24
Can someone help me showing me how to iterate through each child record using the parent key (coming from DataKey)

This is my code, so far I am able to firgure out how to get the children records (well the first one because there is no iteration):

Protected Sub DeleteAllChildren()

    Dim myContext As New OLTPEntities
    Dim myRecipeSteps = myContext.RefineRecipeStep.Where("it.Recipe_Id=" & Me.dvRecipeItem.DataKey(0)).First()

    Dim strRecipeSteps = New StringBuilder("")

    strRecipeSteps.Append("[ID]=" & myRecipeSteps.Id & ", ")
    strRecipeSteps.Append("[Recipe_Id]=" & myRecipeSteps.Recipe_Id & ", ")
    strRecipeSteps.Append("[Recipe_ItemNumber]=" & myRecipeSteps.Recipe_ItemNumber & ", ")
    strRecipeSteps.Append("[Recipe_VersionNumber]=" & myRecipeSteps.Recipe_VersionNumber & ", ")
    strRecipeSteps.Append("[ProcessType]=" & myRecipeSteps.ProcessType & ", ")
    strRecipeSteps.Append("[AdditionOrder]=" & myRecipeSteps.AdditionOrder & ", ")
    strRecipeSteps.Append("[IngredientItemNumber]=" & myRecipeSteps.IngredientItemNumber & ", ")
    strRecipeSteps.Append("[AdditionType]=" & myRecipeSteps.AdditionType & ", ")
    strRecipeSteps.Append("[RecipePercent]=" & myRecipeSteps.RecipePercent)

    End Sub

Open in new window



Any help is kindly appreciated.

Thank you.
0
Comment
Question by:metropia
1 Comment
 
LVL 27

Accepted Solution

by:
Ark earned 500 total points
ID: 39805497
Dim myRecipeSteps = myContext.RefineRecipeStep.Where("it.Recipe_Id=" & Me.dvRecipeItem.DataKey(0)) '<=== remove First()
For each myStep In myRecipeSteps
Next
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question