在哪里写的数据库和商业逻辑MVC? [英] Where to write Database and Business logic in MVC?
问题描述
由于我学习和Asp.Net MVC应用程序的工作,我想知道什么是更好的地方来写商业逻辑
和数据访问逻辑
在 MVC
。
As I am learning and working on Asp.Net MVC application, I want to know that what is the better place to write Business Logic
and Data Access logic
in MVC
.
我应该在哪里写的数据访问和业务逻辑之间的三层(模型,视图和控制器
)??
Where should I write DataAccess and Business Logic among three layers (Model, View and Controller
) ??
有谁请告诉我写的code这个正确的方法。
Could anybody please tell me the correct way to write the code for this.
场景:我要检索所有员工当员工的名称,如弥%
(我有 SQL程序来执行和检索数据
)
PS:想知道我应该创建业务逻辑类的实例,并在那里我应该创建数据访问层类的实例
先谢谢了。
推荐答案
业务逻辑应该在模型中。
Business logic should be in the Model.
数据访问可以是自己的后您的控制器打电话,或自动在ORM您的控制器将通过调用库
Data Access can either be its own later your Controllers call, or automated in an ORM that your Controller will call through repositories.
一个步行通过覆盖这可以在书呆子晚餐发现,寻找的free下载部分。
A walk-through covering this can be found in Nerd Dinner, look for the free download section.
这篇关于在哪里写的数据库和商业逻辑MVC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!