3

我正在设计一个企业解决方案,它由产品范围内的模块化产品组成,首先使用实体​​框架代码来定义域模型并提供数据访问。服务层中的域逻辑 - 如何最好地引用它并将其公开它

例如解决方案:

ProductRange.Authentication 
ProductRange.Gateway 
ProductRange.OrderSystem 
ProductRange.MarketingSystem 

每个产品(解决方案)将有类似的层,目前:

ProductRange.OrderSystem.Model (contains code first POCOs) 
ProductRange.OrderSystem.DataContext (contains the dbContext) 
ProductRange.OrderSystem.DataAccess (contains the Generic Repository) 
ProductRange.OrderSystem.Service.DomainLogic (contains business logic) 
ProductRange.OrderSystem.Service.ApplicationLogic (contains application logic) 
ProductRange.OrderSystem.Presentation.AdminWebsite 
ProductRange.OrderSystem.Presentation.CustomerWebsite 

有些产品需要访问域逻辑:

各种溶液中

项目特别是他们都需要访问ProductRange.Authentication,而且ProductRange.MarketingSystem需要查询ProductRange.OrderSystem

我想通过WCF服务公开范围内的产品之间的域逻辑。 但我也需要在本地参考产品(例如创建项目参考)。

我应该如何去实施?我应该创建一个WCF服务,例如ProductRange.OrderSystem.WCF调用域逻辑并公开它或者我的域逻辑本身是否是WCF服务?如果是后者,我是否总是必须通过WCF引用我的域逻辑,即使是从本地ApplicationLogic?

我想我正在寻找一些关于什么层的指导以及如何最好地提供解决方案之间的内部连接。

+0

属于http://programmers.stackexchange.com –

+1

问:http://programmers.stackexchange.com/questions/212514/domain-logic-in-service-layer-exposed-as-wcf-service –

回答

0

您可以使用一个(或多个)层暴露你波苏斯作为datacontracts和服务合同。

例如:

ProductRange.Server.DataContracts 
    Product 
    AuthenticationInfo 

ProductRange.Server.ServiceContracts 
    IOrderService 
    IAuthentication 
    Auth(AuthenticationInfo info):AuthenticationResult 

ProductRange.Server.Services 
OrderService 
AuthenticationService(implements IAuthentication interface) 

在客户端,你可以参考这个项目(仅适用于数据合同和服务合同),并通过诸如接口创建透明代理:

var serviceProxy = SomeHelper.CreateServiceProxy<IAuthenticationService>(); 
var result = serviceProxy.Auth(new AuthenticationInfo()); 

另外:你可以使用您的poco课程作为数据合同。如果你想要更好的连接性,那么你需要选择一个绑定(如net.tcp)。