如何通过使用3层架构和entityframwork在我的asp.net webapplication中使用接口。 [英] How to use Interfaces in my asp.net webapplication by using 3 tier architecture and entityframwork.

查看:52
本文介绍了如何通过使用3层架构和entityframwork在我的asp.net webapplication中使用接口。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过使用Entityframwork和3层架构在我的asp.net webapplication中使用接口你可以建议我如何维护接口以及我必须维护接口的方法类型?



是否有更好的方法来维护应用程序中的接口?

I would like to use interfaces in my asp.net webapplication by using Entityframwork and 3 tier architecture could u please suggest me how to maintain interfaces and which type of method i have to maintain interfaces?

Is it better approach that maintaining interfaces in application?

推荐答案

Kumar,我通常遵循这种方法:



放置业务逻辑必须在程序集中实现的域类和接口,称为Domain。这包括I [] Service和I [] Repository接口。域没有任何其他项目的引用。例如ICustomer,ICustomerRepository,ICustomerService。



在另一个程序集中,我放置了所有数据库逻辑,并实现了IRepository接口,ICustomerRepository。



在另一个程序集中,我放置了所有的Service逻辑,并实现了IService接口。 ICustomerService。服务是数据库层和前端层之间的桥梁,可以是ASP.Net或MVC



我发现这种方法有层次非常独立,和代码更可维护。

希望这有帮助!
Kumar, I usually follow this approach :

Place domain classes and interfaces that the business logic must implement in an assembly, called Domain. This includes I[]Service and I[]Repository interfaces. The domain does not have any references to any other project. For example ICustomer, ICustomerRepository, ICustomerService.

On another assembly I put all the DB logic, and implement the IRepository interfaces, ICustomerRepository.

On another assembly I put all the Service logic, and implement the IService interfaces. ICustomerService. Services are the bridge between the db layer and the front end layer, which can be ASP.Net or MVC

I've found this approach in having layers very independent, and a code more maintenable.
Hope this helps!


这篇关于如何通过使用3层架构和entityframwork在我的asp.net webapplication中使用接口。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆