I am working on Visual C# MVC project. I am using EF databse first approach in my model.My project is about developing an appmarket where users can buy apps. I used partial view in home page which will contain details of different apps in different partial views.Like App1 in 1st partial view, App2 in 2nd partial view, so on. For this I used for each loop.
In each partial view there is link called MoreInfo, so when user clicks on that they will go inside MoreInfo page. In database I have fields such as app info, app cost, description etc which will be displayed inside MoreInfo page. All these fields are in one table called Apps table.
When i follow Enumerable.FirstOrDefault approach I am able to retrieve only first record from database. But now my problem is I need to retrieve first record in my first MoreInfo view, second record in second MoreInfo view and so on.
My code for controller is :
public ActionResult MoreInfo()
{
var e = Enumerable.FirstOrDefault(db.AppmarketApps);
return View(e);
}
and in view i used :
@model Market.Models.AppmarketApp
<h3><span class="grey"><a href="#">MARKETPLACE</a> ›</span> @Model.Description</h3>
So here I am getting first record description for all MoreInfo views which I don't want. Thanks in advance.