简体   繁体   中英

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. I'm doing it but what I get is a Item1 object and an Item2 object.

Is there a way that I can query the two stored procedures and combine the result in a single Item2 object?

Write both the query in same procedure like
select value1,value2 from table1 select value3 from table1

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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