oceanicwang / dapper-dot-net

Automatically exported from code.google.com/p/dapper-dot-net
Other
0 stars 0 forks source link

Multipe Resultsets #13

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hello World

We're in an environment where Multiple Resultsets are important.

Is there a plan to support this?

i.e. 
  var results = c.QueryMultiple<Order,IEnumerable<OrderRow>>( ... );
  var order = results.First;
  var rows = results.Second;

.... etc

Original issue reported on code.google.com by icanhasjonas on 27 Apr 2011 at 7:27

GoogleCodeExporter commented 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:

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
See QueryMultiple

Original comment by marc.gravell on 29 Apr 2011 at 5:32