private void detach_PurchaseOrderDetails(PurchaseOrderDetail entity) { this.SendPropertyChanging(); entity.Product = null; }
partial void UpdatePurchaseOrderDetail(PurchaseOrderDetail instance);
partial void DeletePurchaseOrderDetail(PurchaseOrderDetail instance);
private void attach_PurchaseOrderDetails(PurchaseOrderDetail entity) { this.SendPropertyChanging(); entity.PurchaseOrder = this; }
partial void InsertPurchaseOrderDetail(PurchaseOrderDetail instance);
public void TestEntityCaching_NewEntities() { CatalogEntityContainer container = new CatalogEntityContainer(); // add two orders and a detail PurchaseOrder order1 = new PurchaseOrder(); PurchaseOrder order2 = new PurchaseOrder(); PurchaseOrderDetail detail = new PurchaseOrderDetail(); container.GetEntitySet<PurchaseOrder>().Add(order1); container.GetEntitySet<PurchaseOrder>().Add(order2); container.GetEntitySet<PurchaseOrderDetail>().Add(detail); // examine the order ref of the detail - ensure that // no result is returned, since a FK query would match // BOTH orders Assert.IsNull(detail.PurchaseOrder); // now that we've cached a null, make sure that if more // new entities are added, the ref doesn't change container.GetEntitySet<PurchaseOrder>().Add(new PurchaseOrder()); Assert.IsNull(detail.PurchaseOrder); // now assign order1, and remove order2 - make sure that our // ref to order1 remains detail.PurchaseOrder = order1; Assert.AreSame(order1, detail.PurchaseOrder); container.GetEntitySet<PurchaseOrder>().Remove(order2); Assert.AreSame(order1, detail.PurchaseOrder); container.GetEntitySet<PurchaseOrder>().Remove(order1); Assert.IsNull(detail.PurchaseOrder); }
public void TestEntityRefCaching_Detach() { CatalogEntityContainer container = new CatalogEntityContainer(); PurchaseOrderDetail detail = new PurchaseOrderDetail { PurchaseOrderDetailID = 1, PurchaseOrderID = 1 }; PurchaseOrder order = new PurchaseOrder { PurchaseOrderID = 1 }; container.LoadEntities(new Entity[] { order, detail }); Assert.AreSame(order, detail.PurchaseOrder); // now detach the detail and verify that the // cached entity is still returned container.GetEntitySet<PurchaseOrderDetail>().Detach(detail); Assert.AreSame(order, detail.PurchaseOrder); }
public void TestEntityRefCaching() { CatalogEntityContainer container = new CatalogEntityContainer(); PurchaseOrderDetail detail = new PurchaseOrderDetail { PurchaseOrderDetailID = 1, PurchaseOrderID = 1 }; PurchaseOrder order = new PurchaseOrder { PurchaseOrderID = 1 }; PurchaseOrder order2 = new PurchaseOrder { PurchaseOrderID = 2 }; container.LoadEntities(new Entity[] { order, order2}); container.LoadEntities(new Entity[] { detail }); // force the EntityRef to cache Assert.AreSame(order, detail.PurchaseOrder); // clear the entity set to verify that the cached // entity is cleared EntitySet purchaseOrderSet = container.GetEntitySet<PurchaseOrder>(); purchaseOrderSet.Clear(); Assert.AreEqual(0, purchaseOrderSet.Count); // after the set has been cleared, we expect null Assert.IsNull(detail.PurchaseOrder); // change the FK and verify that we requery again, getting no match // since all orders have been cleared from the set detail.PurchaseOrderID = 2; Assert.AreSame(null, detail.PurchaseOrder); // Reload the order entities and verify we get the // correct order container.LoadEntities(new Entity[] { order, order2 }); Assert.AreSame(order2, detail.PurchaseOrder); // reset the FK and verify that we requery to get the // right entity detail.PurchaseOrderID = 1; Assert.AreSame(order, detail.PurchaseOrder); }
public void TestEntityCollectionCaching() { CatalogEntityContainer container = new CatalogEntityContainer(); PurchaseOrder order = new PurchaseOrder { PurchaseOrderID = 1 }; PurchaseOrderDetail detail1 = new PurchaseOrderDetail { PurchaseOrderID = 1, PurchaseOrderDetailID = 1 }; PurchaseOrderDetail detail2 = new PurchaseOrderDetail { PurchaseOrderID = 1, PurchaseOrderDetailID = 2 }; container.LoadEntities(new Entity[] { order, detail1, detail2 }); Assert.AreEqual(2, order.PurchaseOrderDetails.Count); // now add a couple new details PurchaseOrderDetail detail3 = new PurchaseOrderDetail(); PurchaseOrderDetail detail4 = new PurchaseOrderDetail(); order.PurchaseOrderDetails.Add(detail3); order.PurchaseOrderDetails.Add(detail4); Assert.AreEqual(4, order.PurchaseOrderDetails.Count); // now modify the parent FK, which will cause the cached // results to be reset, but we expect the explicitly added // entities to be retained // Here we're using ApplyState to allow us to set a PK member w/o validation failure // since PK members cannot be changed. This test should really be based on an association // not involving PK, but the test is still valid this way. order.ApplyState(new Dictionary<string, object> { { "PurchaseOrderID", 2 } }); Assert.AreEqual(2, order.PurchaseOrderDetails.Count); Assert.IsTrue(order.PurchaseOrderDetails.Contains(detail3)); Assert.IsTrue(order.PurchaseOrderDetails.Contains(detail4)); }
private bool FilterPurchaseOrderDetails(PurchaseOrderDetail entity) { return (entity.PurchaseOrderID == this.PurchaseOrderID); }
private void DetachPurchaseOrderDetails(PurchaseOrderDetail entity) { entity.PurchaseOrder = null; }
private void AttachPurchaseOrderDetails(PurchaseOrderDetail entity) { entity.PurchaseOrder = this; }