I am new to linq and asp.net mvc and right now i am developing a project based on Asp.net mvc
using Linq to sql as a data access technology.But i am very confuse about the way of using linq to sql classes.Is it good practice to create a new class for each entity on dbml file and map between them and use that newly created class to our view? If it is bad practice how can i validate the entities using Data Annotation.
I am new to linq and asp.net mvc and right now i am developing
Share
Linq To Sql classes best remain in the data layer and you pass on pocos around. On these you can make metadata classes which include the dataannotations. What you also see, a best practice, is in the UI layer (MVC) so called viewmodels being used. These are classes that map information from the passed around pocos to dedicated objects which are then used in the View.
A great tool to make all that mapping easier for you is AutoMapper.
I also strongly advice to read the book ASP.NET MVC 2 in action from Manning. Another book that I can strongly advice now is Pro ASP.NET MVC 3 Framework.