dapper -multi-mapping:扁平 sql 返回嵌套对象
我有一家包含地址对象的公司。 SQL 返回是平坦的,我试图获取 Query<>加载所有对象。
cnn.Query<Company,Mailing,Physical,Company>("Sproc",
(org,mail,phy) =>
{
org.Mailing = mail;
org.Physical = phy;
return org;
},
new { ListOfPartyId = stringList }, null, true, commandTimeout: null,
commandType: CommandType.StoredProcedure, splitOn: "MailingId,PhyscialId").ToList();
我也不确定 SplitOn 是否正确。我收到消息:
使用多重映射 API 时,请确保在以下情况下设置 splitOn 参数: 您有除 Id 之外的键参数名称:splitOn
建议会很棒。
Test.cs 中的示例不是代码要求作为查询参数的内容。这些需要更新
I have a company that contains an address object. The SQL return is flat, and I'm tring to get Query<> to load all the objects.
cnn.Query<Company,Mailing,Physical,Company>("Sproc",
(org,mail,phy) =>
{
org.Mailing = mail;
org.Physical = phy;
return org;
},
new { ListOfPartyId = stringList }, null, true, commandTimeout: null,
commandType: CommandType.StoredProcedure, splitOn: "MailingId,PhyscialId").ToList();
I'm not sure if i have the SplitOn correct either. I'm getting the message:
When using the multi-mapping APIs ensure you set the splitOn param if
you have keys other than Id Parameter name: splitOn
Suggestions would be great.
The examples in the Test.cs are not what the code asks for as parameters for the queries. These need to be updated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对我来说这很完美......也许是一个错字?
我看到
PhyscialId
看起来确实很像。for me this works perfect ... perhaps a typo?
I see
PhyscialId
which definitely looks like one.