Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从数据库中删除模型投标记录集合_C#_Asp.net Mvc_Entity Framework - Fatal编程技术网

C# 从数据库中删除模型投标记录集合

C# 从数据库中删除模型投标记录集合,c#,asp.net-mvc,entity-framework,C#,Asp.net Mvc,Entity Framework,我正在使用以下模型绑定代码集合在数据库中添加记录。现在我想删除数据库中的记录。如何从数据库中删除模型绑定集合。如何通过实体框架删除 public class CreateRecipeModel { Public int Id // This is primary key //required public string Name { get; set; } public IList<IngredientModel> Ingredients {

我正在使用以下模型绑定代码集合在数据库中添加记录。现在我想删除数据库中的记录。如何从数据库中删除模型绑定集合。如何通过实体框架删除

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
}
public类CreateRecipeModel
{
Public int Id//这是主键
//必需的
公共字符串名称{get;set;}
公共IList元素{get;set;}
}
公共类IngCreditModel
{        
Public int Id//这是主键
//必需的
公共字符串数量{get;set;}
Public int NId{get;set;}//这是父表的外键
}
看法

@Html.EditorFor(model=>model.Name)
@Html.ValidationMessageFor(modelItem=>model=>model.Name)
对于(var i=0;imodelItem.Components[i].Id)
@EditorFor(modelItem=>modelItem.Components[i].Quantity)
@Html.ValidationMessageFor(modelItem=>modelItem.Components[i].Quantity)
}
@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”/>