c# - Confused between Entity classes Generated By VS and the View Model Class for specific display of Data -


I am new to MVC 4 and have been working on an MVC project for the last few days. I am working with the entity framework I am using the first approach of the database so that I can use VS to automatically generate unit sections based on schema. Convenience used. Earlier I had asked the following questions on the stack overflow: The suggestions given were mainly made on the basis of the creation of the visual model sections. Apart from projecting my chosen column, I am confused about the benefits of creating a visual model class. The generating unit class works well for creation , deletion and updates . I can only use my visual model class if I have users Had to show the list of records. Also keep in mind that my code is almost duplicate of VM class generated unit class

I often go into the following problem:

  [HttpPost] [ActionName ("edit")] Public ActionResult EditService_POST (Service Service) {DAL lib = new VFS_DAL (); Int state = lib.UpdateService (service); If (state == 1) {return redirection tie ("description", new {service_name = service.NAME}); } And {look back ("error"); }} [Http gate] [action name ("edit")] public action result edit service (string service_name) {dll} = New DAL (); ServicesVM service = lib.GetServiceDetails (service_name); // This method changes the object of type service that I created to display service details, but for editing, I need contextual content of type of project, so I have to type the second type of object Returns the Context_Services are both the same and the code is the reason of redundancy View Return ("Editing Service", service); }   

How do I manage such situations Just to show a few selected columns, I have to create a Wu model class or what are its other uses?

How can I handle the above situations so that I can do - the problem of switching between the unit-framework generated class and the original model code which are basically code repeats. What are the best practices in this regard?

Any suggestion suggestions like books and links are welcomed. Thank you.

The data attributes should be shown to validate the model that is useful on your base unit structure sections Or maybe. Since in some cases the class is the same or the same auto mapper can be used to look for maps and model sections among institution structure sections.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -