如何使用现有的 C# 3 层 win 应用程序实现 PetaPoco

发布于 2024-11-25 19:35:16 字数 392 浏览 3 评论 0原文

谁能帮我将我的项目转换为使用 PetaPoco?

这是我的问题。后端是 SQL 2010 数据库 .NET fraimework 4.0

我在 C# 中有一个现有的 3 层 win 应用程序,它使用自定义 DAL - 每个数据调用都使用带有参数的存储过程,并根据需要返回数据集或特定值 - 每个调用都接受数据集引用的参数和 baseClass 参数(基类大部分与数据库表架构相同)

我想用 PetaPoco 替换我的自定义 DAL,但保留

应用程序依赖于预定义基类作为 DTO 的 3 层布局要在 UI-BAL-DAL 之间传递信息,

是否有人有关于如何在 3 层环境中使用 PetaPoco 的应用程序解决方案布局示例/示例代码示例将非常有帮助,

提前致谢... 弗拉德

can anyone help me with converting my project to use PetaPoco?

here is my issue. backend is SQL 2010 database .NET fraimework 4.0

I have an existing 3-tier win app in C# that uses a custom DAL -- each Data call uses stored procs with parameters and either returns dataset or specific value as needed -- each call accepts dataset referenced parameter and baseClass parameter (base class is identical to DB table schema well mostly)

I want to replace my custom DAL with PetaPoco but keep the 3-tier layout

the app is relying on predefined base classes as DTO to pass info between UI-BAL-DAL

does anyone have a sample/example of app solution layout as to how to use PetaPoco in 3-tier enviroment code example would be very helpfull

thanks in advance...
Vlad

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

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

发布评论

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

评论(1

不气馁 2024-12-02 19:35:16

示例并不真正需要

您所要做的就是熟悉 PetaPoco 库。最好的方法是它的文档。它不是一个复杂的库,因此您应该很快就能熟悉它。

如果您还将应用程序分解为每一层(UI、BL、DAL)的项目,那么最简单的方法是创建一个新的 DAL 项目并实现现有 DAL 的所有使用功能,但在此项目中使用 PetaPoco。然后只需更改您的项目引用即可。就是这样。您可以保留您的 POCO/DAO。如果您使用过 IoC,那么它会更容易,因为实例化 DAL 存储库(或您正在使用的任何内容)可能是通过某些 DI 容器完成的。

分层和 PetaPoco

PetaPoco 与应用程序分层无关。如果您在 3 层应用程序中使用它,那就没问题了。

你现在用什么?

您没有提到您现在正在使用哪个 DAL 库(如果有)。如果不这样做,那么使用 PetaPoco 将减少代码行并大大简化对象映射。

Example not really needed

All you have to do is get acquainted with PetaPoco library. The best way is its documentation. It's not a complicated/complex library, so you should get up to speed with it quite quickly.

If you also have you application broken down into projects for each layer (UI, BL, DAL), then the easiest thing to do is to create a new DAL project and implement all used functionality of existing DAL but use PetaPoco in this one. Then just change your project references and voila. That's it. You can keep your POCOs/DAO. If you've used IoC then it will be even easier because instantiating DAL repositories (or whatever you're using) is probably done via some DI container.

Layering and PetaPoco

PetaPoco has nothing to do with application layering. If you use it in 3-tier applicatin that's fine.

What are you using now?

You didn't mention which DAL library (if any) you're using right now. If you don't, then using PetaPoco will result in less lines of code and much simplified object mapping.

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