【发布时间】:2018-06-18 07:38:55
【问题描述】:
我有这些课
public class HomeSection2
{
public HomeSection2()
{
HomeSection2Detail = new List<HomeSection2Detail>();
}
public Guid ID { get; set; }
public string Title { get; set; }
public string Header { get; set; }
public virtual List<HomeSection2Detail> HomeSection2Detail { get; set; }
}
public class HomeSection2Detail
{
public Guid ID { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public string Link { get; set; }
public int? Sequence { get; set; }
public virtual HomeSection2 HomeSection2 { get; set; }
}
当我打电话时
var obj2detail = obj2.HomeSection2Detail.Where(w => w.ID == detail.ID).FirstOrDefault();
if (obj2detail != null)
{
obj2.HomeSection2Detail.Remove(obj2detail);
}
从我的应用程序中,它只会删除关系,但不会删除数据库中的记录。
【问题讨论】:
-
obj2的类型是什么? -
@MohammedNoureldin:
HomeSection2
标签: c# asp.net-mvc entity-framework asp.net-core-mvc ef-core-2.0