解耦应用程序设计中的非 POCO ORM

发布于 2024-10-10 08:59:07 字数 418 浏览 0 评论 0原文

我需要使用 LLBLGEN 或 EF4。 我知道可以将 poco 与 EF4 一起使用,但我需要使用通用方法。 所以我的目标是实现非 poco orm 并将其与域解耦。 这意味着我无法在域中使用 DAL 实体,因为它将耦合,因此我想使用存储库。 如果我在 DAL 和域之间使用一些 DTO,那么我将丢失 DAL 实体的内部状态,并且必须将 DTO 映射和重新映射到实体。这就是为什么我想为每个只有属性声明的实体编写额外的接口。存储库将使用这些接口,并且 DAL 实体不会丢失其状态。 为了在 DAL 中创建新对象,我将使用抽象工厂。

缺点:无需在 DAL 实体中映射重新映射 DTO,DAL 实体不会丢失其状态。 优点:需要编写额外的接口并跟踪实体是否更新并将此修改与接口同步,编写额外的代码来实现抽象工厂(但这并不困难)。

我个人认为是值得的。 您能分享一下您对此解决方案的看法吗?

I need to use LLBLGEN or EF4.
I know that it is possible to use poco with EF4, however I need to use general approach.
So my aim is to implement non poco orm and decouple it from domain.
It means that I can't use DAL entities in Domain as it will be coupled, hence I want to use repositories.
If I use some DTO between DAL and Domain then I'll lose DAL entities internal state and have to map and remap DTO to entity. Thats why I want to write additional interface for each entity that will have just properties declarations. Repositories will use these interfaces and DAL entities won't lose its state.
To create new object in DAL I will use abstract factory.

Cons: no need to map remap DTO in DAL Entity, DAL entities don't lose its state.
Pros: need to write additional interfaces and track if entity is updated and sync this modifications with interface, write additional code to implement abstract factory (however it is not difficult).

I personally think that it worth it.
Could you share your opinion about this solution?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生寂 2024-10-17 08:59:07

你听起来很困惑。您想创建域模型吗?然后就这样做。干燥构建。不要创建单独的属性接口。域模型保存状态,因此导出 DAL 状态。通过内省域模型,映射应该几乎是自动的(所有简单的映射)。

You sound confused. Do you want to create a domain model? Then do so. Build it DRY. Do not create separate property interfaces. The domain model holds the state, so the DAL state is derived. The mapping should be nearly automatic (all the simple mappings) by introspecting the domain model.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文