I'm trying to get all products in my catalog where the value of a custom property is in a predefined array.
var eansstr = "4019238560824;4019238560825";
var eans = eansstr.Split(';');
var products = Product.All().Where(x => x.GetProperty("EAN").GetValue() == eans[0]);
foreach (var p in products) {
@p.Name
}
But I get the error message System.NotSupportedException: System.Object GetValue()
Get all products by custom property in array
Hi all
I'm trying to get all products in my catalog where the value of a custom property is in a predefined array.
But I get the error message System.NotSupportedException: System.Object GetValue()
How to fix?
Took some advice from another thread and changed it to this:
Product.All().Where(x => x.ProductProperties.Any(y => y.ProductDefinitionField.Name == "EAN" && eans.Contains(y.Value)));
Now it works :)
Hi Søren
The problem is that NHibernate can't translate "GetValue()" to SQL.
The solution is quering from the productproperty entity like this:
or like this
(Not tested - hope it points you in the right direction)
is working on a reply...