Does dapper support .net dataset

dapper

Question

in my opinion for dapper.query object there is a datareader, for dapper.Execute there is a ExectureNonQuery object. Correct me if i am wrong .

Can we use dapper for dataset which returns multiple tables?

Expert Answer

No, there is not any built in support for DataSet, primarily because it seems largely redundant, but also because that isn't what dapper targets. But that doesn't mean it doesn't include an API for handling a query that selects multiple results; see QueryMultiple:

using (var multi = conn.QueryMultiple(sql, args))
{
    var ids = multi.Read<int>().ToList();
    var customers = multi.Read<Customer>().ToList();
    dynamic someOtherRow = multi.Read().Single();
    int qty = someOtherRow.Quantity, price = someOtherRow.Price;
}

Note that this API is forwards only (due to the nature of IDataReader etc) - basically, each Read / Read<T> etc maps to the next result grid in turn.




Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why