开发者

Entity framework 3.5sp1 delete all in associated table?

开发者 https://www.devze.com 2022-12-20 12:41 出处:网络
What is the equivalent to: DELETE * from ProductsCategories WHERE Product开发者_运维百科ID = 78

What is the equivalent to:

DELETE * from ProductsCategories WHERE Product开发者_运维百科ID = 78

using entity framework 3.5sp1? Need to delete all categories that belongs to a product.

/M


I have used code similar to this to delete records.

var productCategories = from pc in context.ProductCatgories
     where pc.ProductID == 78;
foreach(var category in productCategories)
{
    context.DeleteObject(category);
}

context.SaveChanges();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号