Solved

Delete multiple rows in Entity Framework

Posted on 2014-01-23
1
560 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 28

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
checkbox group not updating when none of them is selected 11 44
vb.net datagrid point 4 34
Import a excel sheet in a grid 2 45
Read top line from CSV file 14 58
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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