Problem getting image url (System.Collections.Generic.List contains no definition for FirstOrDefault)
Hi!
I have a little product showcase site and I'm trying to list "similar products" at the bottom of the product page. These similar products are based on if they have the same "category" property value.
The code I have so far works except when I'm trying to get the product image url. Then I get the error System.Collections.Generic.List
var productCategory= Model.Content.GetPropertyValue("productCategory");
var productList = Umbraco.Content(2160);
var similarProducts = productList.Descendants("product").Where("Visible").Where("@productCategory.ToString().Contains(@0)", productCategory);
@foreach (var similarProduct in similarProducts.Random(4))
{
<h2>@similarProduct.GetPropertyValue("title")</h2>
<img src="@similarProduct.GetPropertyValue("images").FirstOrDefault().Url
}
I can't figure why the image not showing (I'm using multi media picker for the images and need to get the first one)?
Problem getting image url (System.Collections.Generic.List contains no definition for FirstOrDefault)
Hi!
I have a little product showcase site and I'm trying to list "similar products" at the bottom of the product page. These similar products are based on if they have the same "category" property value.
The code I have so far works except when I'm trying to get the product image url. Then I get the error System.Collections.Generic.List
I can't figure why the image not showing (I'm using multi media picker for the images and need to get the first one)?
A little help would be much appreciated! :)
is working on a reply...