1

I am using following collection of model binding code for add record in database.Now I want to delete record in database.How can i delete collection of model binding from database.How can i delete through entity frame work

public class CreateRecipeModel
{
    Public int    Id // This is  primary key 
    //required
    public string Name { get; set; }
    public IList<IngredientModel> Ingredients { get; set; }
}

public class IngredientModel
{        
    Public int    Id   // This is  primary key
    //required
    public string Quantity { get; set; }
    Public int    NId { get; set; }// This is  foriegn key of Parent table
}

View

@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(modelItem => model => model.Name)
<input type=”button” value=”Add” class=”AddQuantity”/>

for (var i = 0 ; i < Model.Count(); i++)
{
    @Html.HiddenFor(modelItem => modelItem.Ingredients[i].Id)
    @Html.EditorFor(modelItem => modelItem.Ingredients[i].Quantity)
    @Html.ValidationMessageFor(modelItem => modelItem.Ingredients [i].Quantity)

}
<input type=”button” value=”delete” class=”deleteModelBinding”/>
good user
  • 41
  • 4
  • http://stackoverflow.com/questions/2519866/how-do-i-delete-multiple-rows-in-entity-framework-without-foreach – REDEVI_ Jun 17 '16 at 12:21

0 Answers0