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.

  • René Pjengaard 118 posts 702 karma points c-trib
    Jul 14, 2010 @ 16:28
    René Pjengaard
    0

    How to search in product descriptions

    I'm having a problem searching in products. To be more specific, i can´t search in description. Ex:

    This works fine:

    var res = from product in Product.All() where (product.Name.Contains(searchquery.Text.Trim())) select product;

    This does not work:

    var res = from product in Product.All() where (product.GetDescription("da-DK").LongDescription.Contains(searchquery.Text.Trim())) select product;

    Exception thrown:

    UCommerce.EntitiesV2.ProductDescription GetDescription(System.String)

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NotSupportedException: UCommerce.EntitiesV2.ProductDescription GetDescription(System.String)

    Can anyone help me?

     

    Regards
    René

  • Søren Spelling Lund 1797 posts 2786 karma points
    Jul 15, 2010 @ 09:23
    Søren Spelling Lund
    1

    Hi René,

    Try something like this:

    var q = from prod in Product.All() where prod.ProductDescriptions.Where(description => description.CultureCode == "en-US" && description.LongDescription.Contains("some text")).Count() > 0 select prod;

    Whenever possible you want to query against the properties on the objects instead of the methods.

  • René Pjengaard 118 posts 702 karma points c-trib
    Jul 15, 2010 @ 10:28
    René Pjengaard
    0

    Thanks Søren, 

    the world of Linq is new to me, but i can see the flexibility when you first get to know the syntax.

    Regards
    René

  • Søren Spelling Lund 1797 posts 2786 karma points
    Jul 15, 2010 @ 11:21
    Søren Spelling Lund
    0

    It's a really nice way of working with an API once you get used to it. The power and flexibility is really unparalleled.

Please Sign in or register to post replies

Write your reply to:

Draft