I am starting asp.net MVC2 by going through a few tutorials, but they are all too basic when trying to apply this to my real world problem.
I have been following a tutorial based on a simple one table database. I build the data model using ADO.NET Entity Data Model and select to generate the model from database. Then I make a controller for the table, all I do in the controller is list the items, i.e.
private sampleDatabaseDBEntities _dataModel = new sampleDatabaseDBEntities();
public ActionResult Index()
{
return View(_dataModel.TheOnlyTable.ToList());
}
So I am trying to figure out how to start, when the schema is more complex.
Say I have a FruitShop and have a table like Vegetables that references values from another table (Color for example).
Obviously the auto generated code will not work:
<table>
<tr>
<th></th>
<th>
SampleID
</th>
<th>
SampleForeignKeyFieldID
</th>
<th>
SampleForeignKeyFieldID
</th>
<th>
SampleOtherValue
</th>
....
because I need to lookups based on the value in SampleForeignKeyFieldID to another table (Colors from Vegetables table for example)
Infact for this table, I tried just doing the return View(_dataModel.Table.ToList());
but nothing displayed at all. I guess because most fields are referenced elsewhere.
How do I get started building the views for these cases? Is there any tutorial/guide you know of that would help get me started?
Thanks