In my project I have got an actionResult method returning a collection of objects like this:
public ActionResult PartNumberManufacturer(string id)
{
var partNumber = Context.PartNumberTable.Where(x => x.PartNumberId == id);
return PartialView("PartNumberView", partNumber);
}
This is my View
@model IEnumerable<Sales.Model.Part>
@if (Model != null && !string.IsNullOrEmpty(Model.PartNumberManufacturer))
{
@if (Model.PartNumberManufacturer == "Fr")
{
<div>
<p> This product is developed in france </p>
}
@if (@Model.PartNumberManufacturer == "Ger")
{
<p> This Product is developed in Germany </p>
}
}
For some reason when I run my query to search for a partnumber .. it only returns the first found partnumber in the database and it does not query for the others. So after research and research online I found that I need to return a collection and iterate each object in that collection.
How would I iterate my collection abd access each object in the collection??
Thank you