HI All,
I am having an issue in my project and wonder if some can pinpoint me to where i may have gone wrong. so basically in my project i have got an ActionResult method like so
public ActionResult PartNumberManufacturer(string id)
{
var partNumber = _Context.PartNumberTable.FirstOrDefault(x => x.partNumberId == id);
return PartialView("PartNumberView", partNumber);
}
Then this is my view
@if (Model != null && !string.IsNullOrEmpty(Model.PartNumberManufacturer))
{
@if (Model.PartNumberManufacturer == "Fr")
{
<div>
<p> This product is developed in france </p>
</div>
}
@if (@Model.PartNumberManufacturer == "Ger")
{
<p> This Product is developed in Germany </p>
</div>
}
well the above code works fine. but the thing is that if you look back into my ActionResult controller method , i am using :
var partNumber = Context.PartNumberTable.FirstOrDefault(x => x.partNumberId == id);
FirstOrDefault of-course will only return the first found part number in the database.
This isnot what i am looking for i don't want it only to return the first found record , i want it to return all the records that match by the search query in the database. So in order to do and after a few research online i found that i had to return the results into a list and this made me amend my ActionResult method to like this:
public ActionResult PartNumberManufacturer(string id)
{
var _methodOfRepair = Context.PartNumberTable.Where(x => x.PartNumberId == id);
return PartialView("PartNumberView", partNumber);
}
so yeah i get the error message saying that
Quote:
{"'System.Data.Entity.Infrastructure.DbQuery<myproject.model.partnumbertable>' does not contain a definition for 'PartNumberManufacturer'"}
i made those changes. what am i doing wrong here? or is there a different approach i can be recommended to in order to achieve this?
thank you for your time.