开发者

Organization of simple project

开发者 https://www.devze.com 2023-01-01 16:24 出处:网络
I want to create a simple mvc application. It\'s typical task and very simular with phpmyadmin. I have a table and a few operations delete, edit, create new row.

I want to create a simple mvc application. It's typical task and very simular with phpmyadmin. I have a table and a few operations delete, edit, create new row.

                Name  Gender Age   
[delete] [edit] Alex  Male   20 
[delete] [edit] Elza  Female 23 
              开发者_如何学运维           [New person] 

When edit or New person clicked by user application show the following page

Name   [........]
Gender [........]
Age    [........]
            [Save]

I'm very new in asp.net and mvc, can anyone suggest a right project organization or give links to simular applications?


A few guide lines I like to stick with:

  1. Entities should map to database tables
    1. You may want to create ViewModels to show denormalized data.
  2. Actions should be verbs that you perform on your entities
  3. Always use Strongly Typed views, always
  4. Try to keep your controllers lean, less controller code = better
    1. If you need, move code into a "service" class that your controller consumes

Depending on your database choice, I'd probably use Linq-To-SQL to quickly generate my entities and I'd probably wrap them up in a simple repository class. If you using something besides SQL Server, I'd try Entity Framework.

If your scope starts getting bigger, you may want to swap out your generated entities and insert your own DTOs inbetween your MVC app and the database layer.

0

精彩评论

暂无评论...
验证码 换一张
取 消