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.

  • Damian Green 452 posts 1433 karma points
    Jun 15, 2012 @ 10:48
    Damian Green
    0

    Can you query the description is a linq statement?

    I am trying to fire off this linq but getting an error and im guessing its because GetDescription is a function rather than a variable..  Is there an alternate way if i am doing it wrong?

    string searchVal = "test";

     var results = Product.All().Where(p => p.DisplayOnSite == true && p.ParentProductId == null                                         && (p.Name.Contains(searchVal) || p.GetDescription("en-us").DisplayName.Contains(searchVal)));

    The contains() part wors if i just use name but it doesnt like GetDescription.

     

  • Damian Green 452 posts 1433 karma points
    Jun 15, 2012 @ 10:49
    Damian Green
    0

    Sorry that should say display name or description in a linq statement!

    Now 5 is binned can we get the Edit fixed on first post? :)

     

  • Søren Spelling Lund 1797 posts 2786 karma points
    Jun 18, 2012 @ 14:11
    Søren Spelling Lund
    1

    You can do p.ProductDescriptions.Single(x => x.CultureCode == "en-us")

  • Damian Green 452 posts 1433 karma points
    Jun 27, 2012 @ 14:27
    Damian Green
    0

    Thanks Soren.

    It almost got me there but NHibernate was throwing a nasty error when i tried adding contains but i found another of your replies where you used the count and selected the results! I think im picking up new things on the linq side of things as i only use it for basic stuff most of the time.

    I'll add a link to that post if i can find it again.

     

     

Please Sign in or register to post replies

Write your reply to:

Draft