Closed Begl4 closed 11 years ago
Not at this moment, however multi result set support is on my to-do list, but I can't tell you when I'll add this feature.
Ok no rush. How about second question, maping Blog and especialy prop Posts in Blog ?
PS :very like SQLFu
Those will have to be done manually for now, SqlFu doesn't handle collections in multi poco mapping.
Ok,Thx for replay.
Did this get implemented? I'd happily settle for partial support via something like the following:
var reader = db.WithSql(sql, new {...}).ExecuteReader();
At least that way, I could iterate the reader manually and use reader.NextResult()
for multiple result sets. WithSql()
would still save me a lot of code setting up parameters, command, connection, etc.
You could get 'partial' support, by checking out the devel branch where there is an extension method (was internal, made it public now) that gives you a command to use
using (var cmd = db.CreateAndSetupCommand(sql, args))
{
//do whatever
}
That's great! Thank you.
I went one step further (to save even more code) and made PocoFactory.GetPocoMapper
Lastly, as my way of pulling this off, I created a few new extension methods with signatures like the following:
public static Tuple<List<T1>, List<T2>> Fetch<T1, T2>(...) {...}
public static Tuple<List<T1>, List<T2>, List<T3>> Fetch<T1, T2, T3>(...) {...}
public static Tuple<List<T1>, List<T2>, List<T3>, List<T4>> Fetch<T1, T2, T3, T4>(...) {...}
It's not the most elegant signature and I usually frown on using Tuple<>, but the methods are short to pull off what I needed to for now.
If you could send me a pull request, maybe we can make it a full feature or something.
Mihai,
I will do just that as soon as I'm clear of my upcoming deadline. Thanks again for getting a change that really helped out up so quickly earlier.
I'll be in touch via Github!
-Matt
On Thu, Jul 25, 2013 at 3:09 AM, Mihai Mogosanu notifications@github.comwrote:
If you could send me a pull request, maybe we can make it a full feature or something.
— Reply to this email directly or view it on GitHubhttps://github.com/sapiens/SqlFu/issues/6#issuecomment-21536913 .
Are multiple result set support posibile with SqlFu ?
Example :
public class Data { public int Int1 { get; set; } public string Str { get; set; } public int Int2 { get; set; } }
var data2 = db.FetchMultiple<int, string, int, Data>((x,y,z) => { var data = new Data {Int1 = x[0], Str = y[0], Int2 = z[0]}; return data; }, "select 1;select 'hi';select 5");
And how to populate Posts in Blog :
public class Blog { public int ID { get; set; } public string Topic { get; set; } public List < Post > Posts { get; set; } }
public class Post { public int ID { get; set; } public string Comment { get; set; } }