ProductTags
TagID PK
Name nvarchar(50) [not null]
还有一张这样的M2M地图:
ProductTagMap
ProductID PK
TagID PK
现在假设我从一个产品中移除一个标记关系(或所有标记关系),如下所示:
// get our Product we are working on...
Product product = dataContext.Products.Where(p > p.ProductID = 1);
// this remove the link between the product and its tags
dataContext.ProductTagMaps.DeleteAllOnSubmit(product.ProductTagMaps);
//*** If these product-specific Tag/s is/are no longer used ***/
//*** by any other Products I'd like to delete them ***/
//*** How can this be done here? ***/
dataContext.SubmitChanges();
这些
标签(与特定产品相关)不再与我希望删除的任何产品相关。
如何在上面的代码中完成此操作(请参阅注释)?