将数据编入/编出插件的最佳方法是什么?

发布于 2024-11-04 13:16:37 字数 419 浏览 0 评论 0原文

我正在使用 MEF 和 EntityFramework 4 构建我的工作站代理应用程序。

该应用程序是一个简单的代理,在具有插件架构(以及许多 .dll 文件形式的插件)的计算机上运行。

每个插件都会查询自己的插件特定表。主程序(或代理)需要将信息传递给插件,并从插件接收信息。

插件将使用实体框架 4.1 来检索数据,因此它已经将数据格式化为对象(可能是重对象,因为它们与 EF 上下文绑定)。另外,我从数据库中提取的数据是一系列联接,因此数据与我已经创建的任何 POCO 身份/类都不匹配。

将数据编入/编出插件的最佳方法是什么?考虑到我正在使用 MEF 将各个部分连接在一起,并且我已经在插件中拥有了数据对象。我应该创建一个新的 POCO 并将实体数据移入其中,然后对数组进行洗牌吗?我应该创建一个列表吗?我不仅对可以做什么感兴趣,而且对最佳实践感兴趣!

I am building my workstation Agent application using MEF and EntityFramework 4.

The application is a simple agent that runs on a computer with a plug-in architecture (and many plugins in the form of .dll files).

Each plug-in will query their own plugin-specific table. The master program (or agent) needs to pass information to the plug-in, and receive information from the plug-in.

The plug-ins will use the Entity Framework 4.1 to retrieve the data, so it will already have the data formatted as objects (perhaps heavy objects since they are tied to the EF context). Also, the data I am pulling back from the database is a series of joins, so the data doesn't match any of the POCO identities/classes I had already created.

What is the best way to marshall data in/out of the plug-ins? Taking into consideration that I am using MEF to tie the pieces together, and that I already have objects for the data in the plug-ins. Should I create a new POCO and move the Entity Data into it, then shuffle arrays? Should I create a List? I am not only interested on what can be done, but what are best practices!

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

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

发布评论

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

评论(1

忆梦 2024-11-11 13:16:37

这是一篇关于数据传输对象的好文章。它涉及到您在 POCO 对象中提出的要点。由于您构建的应用程序具有进一步扩展和自定义的明确意图,因此我认为 POCO 对象是正确的选择。否则,任何其他组件都需要依赖 EF,这对于插件开发人员来说可能是一个负担。使用 POCO/DTO 对象,您将可以更好地控制发送的内容以及发送的结构。

插件应该实现(虚拟?)基类或接口。我可能会选择接口,因为对于插件开发人员来说,将接口添加到他们的代码中比基类更容易。

真的,我并不是在说任何你、奥马尔和冒险还没说过的新话。基本上我是说我认为你已经很好地掌握了它:)

This is a good article on Data Transfer Objects. It touches on the points you are bringing up here with the POCO objects. Since your building an application with the explicit intent of further expansion and customization, I think that the POCO objects are the way to go. Otherwise, any further components will require dependencies on EF which may be burdensome for the plugin developers. With the POCO/DTO objects, you will have a lot more control over what gets sent and what structures it gets sent in.

The plugins should either implement a (virtual?) base class or an interface. I would probably choose interface because - again - it will be easier for plugin developers to add an interface to their code than a base class.

Really, I'm not saying anything new that you, Omar and Adventure haven't already said. Basically I am saying that I think you've already got a good handle on it :)

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