因此,为了便于您执行此操作,这是一个简单的示例,您可以理解( 有更好,更复杂的方法 )。
private void AddProducts(double salePrice, int taxValue){ using (var ctx = new Entity()) { Product prodObject = new Product { PId = //NEW ID, SalePrice = salePrice }; Product_tax pTax = new Product_tax { pid = prodObject.PId, taxid = taxValue }; ctx.product.AddObject(prodObject); ctx.Product_tax .AddObject(pTax); ctx.SaveChanges(); }}这应该通过调整您的解决方案来解决。



