c# - How to retrieve one record at a time from SQL Server database in MVC Model -
i working on visual c# mvc project. using ef databse first approach in model.my project developing appmarket users can buy apps. used partial view in home page contain details of different apps in different partial views.like app1 in 1st partial view, app2 in 2nd partial view, on. used each loop.
in each partial view there link called moreinfo, when user clicks on go inside moreinfo page. in database have fields such app info, app cost, description etc displayed inside moreinfo page. these fields in 1 table called apps table.
when follow enumerable.firstordefault approach able retrieve first record database. problem need retrieve first record in first moreinfo view, second record in second moreinfo view , on.
my code controller :
public actionresult moreinfo() { var e = enumerable.firstordefault(db.appmarketapps); return view(e); }
and in view used :
@model market.models.appmarketapp <h3><span class="grey"><a href="#">marketplace</a> ›</span> @model.description</h3>
so here getting first record description moreinfo views don't want. in advance.
expanding on comment should use id of application , pass moreinfo
this:
public actionresult moreinfo(int id) { var e = db.appmarketapps.where(x => x.id == id).firstordefault(); return view(e); }
Comments
Post a Comment