I have two tables:
Countries(Country_ID,Country_Name) here Country_ID is primary key
States(State_Id,State_Name,Country_ID) here Country_ID is foreign key
When I design Index page for States: url(http://localhost:2010/States/Index)
StatesController.cs contains this code:
//I am using LINQ and datacontext object with name db and a function db.GetStates() returns list of State objects
index(){
return view(db.GetStates());
}
Folder Structure of Application is:
Application-View-States-Index.aspx and when I execute this page it shows result as Country_ID (1,India)
State_ID State_Name Country_ID
1 Punjab 1
but I want to show:
State_ID State_Name Country_Name
1 Punjab India
but model object or item object of model contains only a list of States object which only contains Country_ID instead of Country_Name.
If anybody has any such sample application that using LINQ in Model, MVC and have parent child relationship tables.