public void UpdateID(int postid) { Debug.Assert(ProductId != 0); using (var repository = new TradelrRepository()) { var w = repository.GetProduct(ProductId).wordpressPosts; if (w == null) { w = new wordpressPost(); repository.AddWordpressPost(w); } w.productid = ProductId; w.postid = postid; repository.Save(); } }