Closed GoogleCodeExporter closed 8 years ago
Here's an addon that extends dapper-dot-net with QueryMultiple<T0,...Tn>()
The addon is a t4 script that generates all needed.
(You need to add the 'partial' keyword to SqlMapper.cs to enable this)
Original comment by icanhasjonas
on 27 Apr 2011 at 9:20
Attachments:
I created an implementation that uses hard coded
Tuple<IEnumerable<T1>...IEnumerable<T7>> overloads for my multiple result set
method with logic similair to the MultiMap methods.
But T4 version is more flexible, in fact making SqlMapper partial as default
would be great to keep any generated/custom/test/unstable code sepearate from
the main source tree.
Original comment by mattias%...@gtempaccount.com
on 27 Apr 2011 at 10:46
Im happy with the Tuple implementation, can you submit a patch, also happy to
change the class to a partial, but would like to avoid T4 if possible for now.
Also be sure it chucks an exception if someone asks for an unbuffered multi rs,
getting that to work is kind of complex, we would need a custom tuple class.
and it would be very finicky.
Original comment by sam.saff...@gmail.com
on 28 Apr 2011 at 12:21
Sure will clone, cleanup and commit clone url here for possible merge.
Original comment by mattias%...@gtempaccount.com
on 28 Apr 2011 at 9:36
Clone submitted to:
https://mattias%40amigarulez.se@mattias-query-multiple-reader-resultsets.googlec
ode.com/hg/ mattias-query-multiple-reader-resultsets
Original comment by mattias%...@gtempaccount.com
on 28 Apr 2011 at 10:23
Mattias,
was chatting to Marc about this and we feel the Tuple stuff is a tad clunky, we
are thinking about the following API
using (var rs = cnn.QueryMulti(sql))
{
var orders = rs.Read<Order>(bufferd: false);
var customers = rs.Read<Customer, Address>((c,a) => c.Address = a);
}
Thoughts?
This would allow us to reuse and streamline the rest of our stuff.
Original comment by sam.saff...@gmail.com
on 28 Apr 2011 at 1:00
Sam - That's alot nicer - currently we're integrating on a customer where 20+
result sets are not uncommon...
Original comment by icanhasjonas
on 28 Apr 2011 at 1:24
I have a working version of the above API - about 40 lines of code, so quite
succinct. Will commit when Sam has sanity-checked it for me
Original comment by marc.gravell
on 28 Apr 2011 at 2:22
See QueryMultiple
Original comment by marc.gravell
on 29 Apr 2011 at 5:32
Original issue reported on code.google.com by
icanhasjonas
on 27 Apr 2011 at 7:27