in a for loop I receive results from a db as dynamic type
dynamic {system.collections.generic.List<object>}
I need to collect these results into one single variable.
I tried defining a variable
dynamic results = new List<object>();
and then
var queryResults = _dbManager.Query(query);
results = results.Concat(queryResults);
but I have this exception:
System.Collections.Generic.List<object> does non contain a definition for 'Concat'
I can't find a solution. Do you how can I do this? Thanks!
The problem is that dynamic types and extension methods don't work well together (read the explanation of Eric Lippert on the why). You have to call the extension method yourself as a static method (which it actually is):
var l = Enumerable.Concat(results, queryResults);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With