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.
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.
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é
Hi René,
Try something like this:
Whenever possible you want to query against the properties on the objects instead of the methods.
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é
It's a really nice way of working with an API once you get used to it. The power and flexibility is really unparalleled.
is working on a reply...