Search code examples
asp.net-mvclinq-to-sqlmodelpresentation

LINQ vs. presentation model


Does LINQ substitute the presentation model?

I read in the book "ASP.NET MVC in Action" about presentation models.

I wonder why to build a presentation model?!

For instance, projecting a domain object (entity) by creating a new class at runtime via LINQ is in my opinion more comfortable than creating dozens of presentation objects.

So what do you think? Maybe someone of you use both :o

Technologies I would prefere are ASP.NET MVC and NHibernate with LINQ or the Entity Framework.


Solution

  • Linq does not substitute for the presentation model. Nor does Linq to SQL, if that is what you are referring to (which it probably is). Rather, Linq to SQL maps database tables to C# or VB classes, so that you can work with the data directly in your code.

    A presentation model (or View Model in ASP.NET MVC) is a code class that is used to decouple your view from the data model or business classes. The View Model allows you to put things like validation and view logic into it, without it cluttering up your view.

    Remember that Domain-Driven-Design (DDD) at its core is really just a method for establishing a common vocabulary (the "ubiquitous language") between you and your customer so that the process of design is made easier and more accurate.

    Be sure you check out the NerdDinner tutorial at nerddinnerbook.s3.amazonaws.com/Intro.htm. View Models are discussed in detail at nerddinnerbook.s3.amazonaws.com/Part6.htm