Dapper-dot-net“无列名”
我的结果集可能如下所示:
ID (no column name) anotherID
---- ---------------- ----------
1 super 3
1 super 4
3 duper 6
4 really 7
4 really 8
我有 2 个问题:
第一: 如何对没有名称的列使用 dapper?
第二:我想要建立一个父子关系,这样我就可以得到 3 个对象,每个对象都有一个 anotherID 的列表,例如:
public class MyObject
{
public int ID
public string Name
public int[] Children
}
I have a result set that might look like this:
ID (no column name) anotherID
---- ---------------- ----------
1 super 3
1 super 4
3 duper 6
4 really 7
4 really 8
I have 2 issues:
First: How do I use dapper with a column with no name?
Second: I want to have a parent child relationship such that I get 3 objects each with a list of anotherID's for example:
public class MyObject
{
public int ID
public string Name
public int[] Children
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,dapper 不支持未命名的列。我从来没有真正看到他们的理由。
我想我们可以建立对以下内容的支持:
问题是它引入了一种非常脆弱的查询方法,我非常不喜欢这种方法,将指令传递给
Query
也同样笨拙。但是,如果您愿意改变获取结果的方式,则可以解决此问题。
然后使用此处的技术进行多重映射: Multi-Mapper创建对象层次结构
Well, un-named columns are not supported by dapper. I never really saw a reason for them.
I guess we could build support for:
The trouble is that it introduces a very fragile method of querying which I strongly dislike, passing a directive to
Query
is just as clunky.However, if you are happy to change the way you grab the results you could work around this.
Then use the technique here to multi map: Multi-Mapper to create object hierarchy