Hello,
I really need some help with this, please.
I have a Model called CategoryMenu. It's a checkbox list which gives an IEnumerable string
I'm using the same DataType but used inside a Portfolio model.
I am now trying to render this in a parial view and need to Join these lists to get the sequence number from the Category menu, but I'm getting errors no matter what I try.
Here are some code snippets...
//IEnumerable list
var categories = Model.PortfolioCategoryMenu.Select((name, i) => new { name, i });
// My portfolio IEnumerable list
foreach (var items in portfolio.PortfolioCategories.Select((name, i) => new { name, i }))
{
var cat = from category in categories
join portfolioName in items on category.name equals portfolioName.name
select new { portName = portfolioName, CategoryNumber = category.i };
The errors says, "IEnumerable " does not contain a definition for Join and the best extension method overload requires a receiver of type HtmlHelper
here is the entire partial...
@inherits Umbraco.Web.Mvc.UmbracoViewPage<Home>
@{
// https://www.tutorialsteacher.com/codeeditor?cid=cs-DoAglF
// https://www.tutorialsteacher.com/linq/linq-joining-operator-join
var categories = Model.PortfolioCategoryMenu != null && Model.PortfolioCategoryMenu.Any() ? Model.PortfolioCategoryMenu.Select((name, i) => new { name, i }) : null;
var portfolioItems = Model.Portfolio != null && Model.Portfolio.Any() ? Model.Portfolio : null;
}
<div id="portfolio" class="section lb">
<div class="container">
<div class="section-title text-left">
<h3>@Model.PortfolioTitle</h3>
<p>@Model.PortfolioSummary</p>
</div>
@if (categories != null)
{
<div class="gallery-menu row">
<div class="col-md-12">
<div class="button-group filter-button-group text-left">
<button class="active" data-filter="*">All</button>
@foreach (var item in categories){
<button data-filter=".gal_@(item.i)">@item.name</button>
}
</div>
</div>
</div>
}
<div class="gallery-list row">
@if (portfolioItems != null)
{
foreach (var portfolio in portfolioItems)
{
var image = portfolio.PortfolioImage != null ? portfolio.PortfolioImage : null;
var imageUrl = image != null ? Umbraco.Media(image.Id).Url : string.Empty;
foreach (var items in portfolio.PortfolioCategories.Select((name, i) => new { name, i }))
{
var cat = from category in categories
join portfolioName in items on category.name equals portfolioName.name
select new { portName = portfolioName, CategoryNumber = category.i };
<div class="col-md-4 col-sm-6 gallery-grid @(string.Join("gal_", cat, 0))">
<div class="gallery-single fix">
<img src="@imageUrl" class="img-fluid" alt="@(image != null ? image.Name : string.Empty)">
<div class="img-overlay">
<a href="@imageUrl" data-rel="prettyPhoto[gal]" class="hoverbutton global-radius"><i class="fa fa-picture-o"></i></a>
</div>
</div>
</div>
}
}
}
</div>
</div>
</div>
Really need help on this.
Cheers,
Daniel