尝试使用 PetaPoco 动态加入 POCO?

发布于 2024-12-16 12:39:00 字数 652 浏览 5 评论 0原文

有大约 100 个父表,所有父表都以 RECID 作为标识列。没有两个父项包含相同的 RECID。有一个带有外键 RECID 的子表。

我尝试使用以下想法,其中模糊根据用户需求在 100 个表域中变化:

var stuff = _d.Query<dynamic, sameAgain, dynamic>(
    new Relator().relatem,
    "select * from nebulous as n left join sameAgain on n.RECID = RECID"
    );
...
class dynamic Relator {
    relatem(dynamic parent, sameAgain child)
    {
       // inspired by the most recent blog Multi-POCO in PetaPoco

       ... (parent as IDictionary<string, object>)["RECID"] ...
    }
} 

没有骰子。我进入那里并感到困惑,因为调试器显示的对象不是父级的 ExpandoObjects。所以我尝试用 ExpandoObject 替换动态。

还是没有骰子。所以它仍然是一个有趣的死胡同。有人试过这个吗?

There are ~100 parent tables, all with RECID as their identity column. No two parents contain the same RECID. There is one child table with foreign key, RECID.

I tried using following idea where nebulous varies over the 100 table domain on user demand:

var stuff = _d.Query<dynamic, sameAgain, dynamic>(
    new Relator().relatem,
    "select * from nebulous as n left join sameAgain on n.RECID = RECID"
    );
...
class dynamic Relator {
    relatem(dynamic parent, sameAgain child)
    {
       // inspired by the most recent blog Multi-POCO in PetaPoco

       ... (parent as IDictionary<string, object>)["RECID"] ...
    }
} 

No dice. I got in there and was confused because the debugger showed objects not ExpandoObjects for parent. So I tried replacing the the dynamic with ExpandoObject.

Still no dice. So it remains an interesting dead-end. Has anyone tried this?

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

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

发布评论

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

评论(1

网白 2024-12-23 12:39:00

默认情况下,PetaPoco 通过 PetaPoco.cs 文件顶部的“#define PETAPOCO_NO_DYNAMIC”禁用动态功能。如果您想使用动态功能,请注释掉该行并重建(这当然需要.net 4.0)。如果启用了动态功能并且查询成功,则在调试时记录将显示为 ExpandoObject,而不是对象。

By default, PetaPoco disables the Dynamic feature with '#define PETAPOCO_NO_DYNAMIC' at the top of the PetaPoco.cs file. If you want to use the Dynamic feature, comment that line out and rebuild (this of course requires .net 4.0). If the Dynamic feature is enabled and the query is successful, records will show up as an ExpandoObject when debugging instead of an Object.

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