简体   繁体   English

Dapper:我可以将两个存储过程查询到一个对象中吗

[英]Dapper: Can I query two stored procedures into one object

I have this: 我有这个:

public class Item1 {
    public string Value1;
    public string Value2;
}


public class Item2: Item1 {
    public string Value3;
}

I want to query two stored procedures, one returns Value1 and Value2, and the other returns Value3. 我想查询两个存储过程,一个返回Value1和Value2,另一个返回Value3。 I'm doing it but what I get is a Item1 object and an Item2 object. 我正在做,但是得到的是一个Item1对象和一个Item2对象。

Is there a way that I can query the two stored procedures and combine the result in a single Item2 object? 有没有一种方法可以查询两个存储过程并将结果合并到单个Item2对象中?

Write both the query in same procedure like 用相同的过程编写两个查询
select value1,value2 from table1 select value3 from table1 从表1中选择value1,value2从表1中选择value3

Accept Result in dataset instead of datatable 在数据集中而不是数据表中接受结果

DataSet ds=new DataSet();
Adp.Fill(ds);
    ds.Tables[0].Rows[0]["Value1"].ToString();
    ds.Tables[0].Rows[0]["Value2"].ToString();
    ds.Tables[1].Rows[0]["Value3"].ToString();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM