private bool FilterItems(CartItem entity)
 {
     return (entity.CartItemId == this.CartId);
 }
 private void AttachItems(CartItem entity)
 {
     entity.Cart = this;
 }
 private void DetachItems(CartItem entity)
 {
     entity.Cart = null;
 }
        public void InsertThrows_AssociationCollectionPropertyIsNull()
        {
            TestProvider_Scenarios provider = new TestProvider_Scenarios(TestURIs.TestProvider_Scenarios);
            SubmitOperation so = null;

            Cart c = new Cart();
            c.CartId = 1;
            CartItem ci1 = new CartItem()
            {
                CartItemId = 1,
                CartId = c.CartId,
                Cart = c,
                Data = "Cart item #1 data"
            };
            CartItem ci2 = new CartItem()
            {
                CartItemId = 2,
                CartId = c.CartId,
                Cart = c,
                Data = "Cart item #2 data"
            };
            provider.Carts.Add(c);
            provider.CartItems.Add(ci1);
            provider.CartItems.Add(ci2);

            so = provider.SubmitChanges(TestHelperMethods.DefaultOperationAction, null);
            EnqueueConditional(() => so.IsComplete);
            EnqueueCallback(delegate
            {
                Assert.IsNotNull(so.Error);
                Assert.AreEqual(string.Format(Resource.DomainContext_SubmitOperationFailed, "One or more associated objects were passed for collection property 'Items' on type 'Cart', but the target collection is null."), so.Error.Message);
                Assert.IsNotNull(so.ChangeSet);
                Assert.AreEqual(3, so.ChangeSet.AddedEntities.Count);
            });
            EnqueueTestComplete();
        }