Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ASP.NET MVC Model
Message
De
07/07/2013 14:31:07
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 9.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01577926
Message ID:
01577927
Vues:
63
J'aime (1)
A Model should "model" what the database looks like. What you need is a ViewModel.

Keeping it simple, the controller will call multiple models to populate the ViewModel. A ViewModel is a model used just for a view. It doesn't actually talk to the database, just handles data for the View. I have a blog series on unit testing MVC and one post talks about setting up the SelectList. It may be of help to you.
See http://www.craigberntson.com/blog/?p=1123

Eventually, you'll want to pull this kind of stuff out of the Controller as it should be a very thin layer. But for now, don't overcomplicate your learning.


>I am learning how to create Model using EF (learning from various Pluralsight courses). So far what I understood is that the controller creates a model from EF and passes it to the View. And the examples I watched - so far - deal with only one table. But what if I need to use more that one table in the View? For example, a "main" table for the fields of the View and several tables used as look-ups? Does it mean that the controller then creates several models and passes to the View not one but several Models?
>
>TIA.
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform