开发者

Entity framework 3.5sp1 delete all in associated table?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜