I am really struggling to understand why, when I change my code to use a lamdba expression, it doesn't work.
This code works and prints on console:
object dummy = new object();
InterServer.ExecuteDataReader(new InterServerRequest(ServerID.a_01, "dbo.getbooks")
{
Params = new Dictionary<string, object> {
{ "Tool", "d1" },
{ "Loc", locale == string.Empty ? null : locale } }
},
(_, reader) =>
{
reader.AsEnumerable(r => (r.GetString(r.GetOrdinal("book")))).ToList().ForEach(Console.WriteLine);
return new Response(dummy);
}
);
This code has been changed to use a lambda expression; it doesn't print anything, I don't understand why:
InterServer.ExecuteDataReader(new InterServerRequest(ServerID.a_01, "dbo.getbooks")
{
Params = new Dictionary<string, object> {
{ "Tool", "d1" },
{ "Loc", locale == string.Empty ? null : locale } }
},
(_, reader) =>
{
return new Response(new Action(() =>
reader.AsEnumerable(r =>(r.GetString(r.GetOrdinal("book")))).ToList().ForEach(Console.WriteLine)));
}
);
This is really driving me mad as I don't see if I am doing anything wrong. Can someone help?
Thanks, AG