Problem with simple self servicing save scenario

Posts   
 
    
Posts: 34
Joined: 20-Apr-2005
# Posted on: 02-Mar-2007 15:42:14   

I am attempting to save a new entity recursively, after having added an item to its child collection.

The following:


            BasketEntity basket = new BasketEntity();
            BasketLineEntity line1 = basket.BasketLines.AddNew();

            ProductEntity product = new ProductEntity(1024);
            line1.ItemPrice = (decimal)product.Price;
            line1.ItemSalesTax = 0;
            line1.ItemUpgradePrice = 0;
            line1.Product = product;
            line1.Quantity = 1;

            basket.Save(true);

Fails, it attempts to insert the basketline entity first and throws "SQlExceptionCannot insert the value NULL into column 'BasketID'"

The project uses the 19th feb release of the RTL.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 02-Mar-2007 16:01:28   

basket isn't saved since there was no field set to any value, so the entity was not dirty (entity.IsDirty=false) and there was no changed field (field.IsChanged = false)

Posts: 34
Joined: 20-Apr-2005
# Posted on: 02-Mar-2007 16:04:12   

Aha, thanks. Thought it would be something simple.