【发布时间】:2011-01-06 19:48:54
【问题描述】:
我看到我正在开发的网络应用程序中大量使用“存储”对象。这种模式有名称吗?你会说这些类型在 BLL 或 DAL 中吗?
这些存储包含我认为是经典 DAL 类型的片段,与单一类型相关联。
例如,我们有一个 TabStore,其中包含用于持久化和检索选项卡的方法。在 TabStore 的每个方法中,都有调用相应 NHibernate 查询的代码。
使用这种模式有哪些陷阱(如果有的话)?将曾经可能是单一的 Dal 类型分离为更易于管理、更小的类型真的是一种简单的尝试吗?
示例方法:
public IList<Tab> GetAllTabInstancesForUserId(Guid userId)
{
IList<Tab> tabInstances =
UoW.Session.CreateQuery("from Tab t where t.UserId=:userId order by t.TabOrder")
.SetGuid("userId", userId)
.SetCacheable(true)
.List<Tab>();
return tabInstances;
}
【问题讨论】:
-
商店是一个非常模糊的词。如果您期望得到一个体面的答案,可能需要更多上下文。
标签: asp.net-mvc datastore