0

To update an Entity of database (table) we directly inherit Model Entity to view page like

<%@ Page Title="Edit" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MVCProject.Models.Preson>" %> 

And Then Post method of Edit is called from controller, and at last, Entity updates By savechanges method of LINQ class or EF.

But user should allowed to update "Preson" Entity only for selected fields, rest of the fields should set automatically.

User should have only selected values, to be editable in his view. And the Entity should be inherited from our service layer e.g. <MVCProject.ServiceLayer.Preson>.

This would be the best way to split application into tires.

Now, Anybody knows, How to create classes in service layer, and map them to databasecontext (in case of LINQ class)?

1
  • For mapping... look into automapper jimmy bogard Commented Apr 4, 2011 at 7:53

2 Answers 2

2

To update selected values,

  1. Use a viewmodel approach
  2. Within the controller allow only certain values to be binded (Include or Exclude)
Sign up to request clarification or add additional context in comments.

1 Comment

+1 for ViewModel approach. I don't think service layer is really what you want here.
0

Examine this tutorial, it has heaps of info about abstracting away a Service layer for an MVC application.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.