This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi folks, Couldn't find an answer to this.. hopefully it's a fairly simple question. We're using LightSpeed 2, and we've got a Cart entity (containing shopping cart data) and a Promotion entity. Customers can possible add a Promotion to their Cart using a code before checking out, in order to get the discount corresponding to the promotion code they entered. We also want the customer to be able to remove a previously-added promotion, by clicking a remove link. We're trying to achieve this by setting Cart.Promotion = null, and were expecting this to automatically set Cart.PromotionId to null, but this doesn't happen. Here's a cut-down example: public class Cart : Entity<int> [ReverseAssociation("Carts")] public Promotion Promotion public int? PromotionId public class Promotion: Entity<int> So assuming a Promotion has been set previously, here is the code we want to remove the Promotion from the Cart: cart.Promotion = null; But while cart.Promotion does become null, cart.PromotionId still contains a valid Promotion ID. Should we be setting cart.Promotion to null, or cart.PromotionId to null? And generally, which should we use to update the associated promotion entity? |
|
|
Either of those should work: I've run tests against the current builds of both LightSpeed 2.2 and LightSpeed 3 and they appear to produce the same result. Specifically, when I set the association to null, the foreign key does also become null. Could you try the latest nightly build (you won't need to upgrade to LightSpeed 3 if you don't want to, we're still shipping nightlies for 2.x I believe) and let us know if you still see the problem? Thanks! |
|
|
Hi Ivan, It would appear that the version of LightSpeed we were using (2.2.948.10429) was the problem. With the latest nightly build of v2 there is no longer an issue.. Thanks for your help Ed |
|