Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Andrei 68 posts 130 karma points
    Nov 02, 2010 @ 15:40
    Andrei
    0

    CategoryProductRelation possible bug

    Hi Søren,

    I have got into a very weird issue: when importing a product, I try to delete all current categories and populate them again. The problem  is that when I call .Delete() on a CategoryProductRelation object it is deleting categories for other products as well. Then after some debugging, I found this in reflector:

    and when I look what KeyValue() returns:

    So when I delete a CategoryProductRelation object it seems that it's deleting all relations to that category. However, this works if done from backend. 

    Any ideea if I am doing something wrong, or how should I delete category relations for a product?

  • Andrei 68 posts 130 karma points
    Nov 02, 2010 @ 15:53
    Andrei
    0

    Ok, I think I found a way, Iinstead of calling Delete() method on CategoryProductRelation instance, I use this:

    CategoryProductRelation.Delete(x => x.ProductId == cpr.ProductId && x.CategoryId == cpr.CategoryId);   

    It seems to do the job.

  • Søren Spelling Lund 1797 posts 2786 karma points
    Nov 03, 2010 @ 09:36
    Søren Spelling Lund
    0

    Hi Andrei,

    You're absolutely correct. Subsonic doesn't handle composite keys very well - that is to say not at all. That's why we're moving to NHibernate for all data access. The relationship between products and categories is one of the very few places where we've got that construct.

Please Sign in or register to post replies

Write your reply to:

Draft