Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Delete multiple rows in Entity Framework

Posted on 2014-01-23
1
Medium Priority
?
575 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

704 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