【发布时间】:2011-06-16 15:46:16
【问题描述】:
我需要一些帮助来一起使用 IRepository 模式和 SOA。
我正在开发一个包含非常复杂的业务逻辑的会计应用程序。目前我正在使用 IRepository 作为 DAL,它只做基本的 CRUD + 事情,比如提供 IQueryable 接口、一些缓存功能等等。
在它之上,我有一个业务逻辑层,它扮演服务层或外观层的角色(它们是同一个东西吗?)。此处封装的所有应用程序逻辑都将被表示层使用的方法。
正如我所说,所有基本的 CRUD 都放置在存储库中,但进一步发生在 BusinessLogic 中,例如,我们的帐户存储库中可能只有这些基本方法:
public class AccountRepository
{
public IList<Accounts> GetAll()
{
...
}
public Accounts Get(int id)
{
...
}
public IList<Accounts Where(Func<Accounts,bool> criteria)
{
...
}
public Accounts Add(Accounts item)
{
...
}
}
但要获得具有特定号码的帐户,我们将提供这样的服务:
public class AccountService
{
AccountRepository repos;
public Accounts FindByNumber(int AccountNumber)
{
return repos.Where(o=>o.AccountNumber == AccountNumber).FirstOrDefault();
}
}
AccountService 还可以有一个 CreateAccount() 方法,该方法通过使用实体存储库和在单个事务中添加多个实体(一个帐户、一个所有者和...)。
现在我想知道我是否以正确的方式使用它们?还是我错过了一些要点?
【问题讨论】:
-
我一直用这个,看看这篇文章 esp。关于网关的部分。 SOA Design Pattern
-
非常感谢,您是如何管理交易的?我的意思是你在哪一层处理它们? (我想到了引擎层)以及如何在这个架构师中实现它们?
标签: design-patterns soa