[英]delete multiple rows from multiple tables by entity
I have entity called product,pic and it has properties. 我有一个称为product,pic的实体,它具有属性。
public class product
{
public virtual int Id;
public virtual long name;
public virtual string title;
}
public class pic
{
public virtual int Id;
public virtual int id_pic;
public virtual string name;
}
the relationship between product(id) and pic(id_pic) . product(id)和pic(id_pic)之间的关系。
Now I need to write a method that Delete row from product table. 现在,我需要编写一个从产品表中删除行的方法。
If the foreign key in pic
is referencing a product
, you should probably name it id_product
. 如果
pic
的外键引用的是product
,则可能应将其命名为id_product
。
Can you post what you've written so far ? 你能发表你到目前为止写的东西吗? You've only posted your two entities and they don't really do anything.
您只发布了两个实体,它们实际上什么也没做。
If you're trying to do a cascading delete, where deleting a product also deletes any associated pics, you have several options including regular ADO.NET, Entity Framework and Lightspeed. 如果您要进行级联删除(删除产品也会删除所有关联的图片),则可以使用多个选项,包括常规的ADO.NET,实体框架和Lightspeed。 I would suggest looking at Fluent NHibernate: - http://www.fluentnhibernate.org/
我建议您查看Fluent NHibernate:-http: //www.fluentnhibernate.org/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.