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”/>