简体   繁体   中英

delete multiple rows from multiple tables by entity

I have entity called product,pic and it has properties.

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) .

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 .

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. I would suggest looking at Fluent NHibernate: - http://www.fluentnhibernate.org/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM