尝试使用 PetaPoco 动态加入 POCO?
有大约 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,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.