I need output information from two tables
public class team {[key ] Public Int TeamID {Receives; Set; } Public Entity ID {Receipt; Set; } Public string TeamName {get; Set; }} Public class TeamType {[Key] Public int TypeId {get; Set; } Public String TypeName {get; Set; } Public Virtual Ilectronics & lt; Team & gt; Teams {receive; Set; }}
I created this class
Public abstract class MyAppController: Controller {// // GET: / MyApp / Private ReengEdities DB = New Reengdict (); Public Rainforestation Datacontext {get {return db; }} Public MyAppController () {ViewBag.TeamList = db.TeamTypes.Include ("Team"). ToList (); }}
I see the following:
@ Renegades.Helpers @model IEnumerable and lt; Renegades.Models.TeamType & gt; @Ventch (ViewBag.TeamList in var t) {& lt; Li & gt; & Lt; Period & gt; @ T.TypeName's & lt; / Span & gt; & Lt; Ul id = "sub_team_menu" & gt; @ Warak (Uniform Team at TATM) {& lt; Li & gt; Team. TEAM name & lt; / Li & gt; } & Lt; / Ul & gt; & Lt; / Li & gt; }
Please help me understand how I output data from two or more tables in my view
If tables are connected to each other through a foreign key like your case, then you can use another table as the property such as teamtype. TAM
. But I think that you are not referring to TeamType
in your team
category.
Edit your class as:
Public class team {[Key] Public Industry Team TeamId {get; Set; } Public Entity ID {Receipt; Set; } Public string TeamName {get; Set; } Public Virtual Team Type Type {get; type
then use to enter
code> The table of assets such as:
@forach (various teams in TATM) {& lt; Li & gt; Team. Type. Type name & lt; / Li & gt; }
But if the tables are not connected to each other then the simple answer is that you will have to create ViewModel
for this now see what's the model, which is not so easy Follow the link to study about modal:
Here's a more straightforward link:
Comments
Post a Comment