Comments on: LINQ Abuse with the C# 4 dynamic type http://jrwren.wrenfam.com/blog/2010/03/04/linq-abuse-with-the-c-4-dynamic-type/ babblings of a computer loving fool Mon, 21 Nov 2016 19:37:12 +0000 hourly 1 https://wordpress.org/?v=4.7.2 By: jrwren http://jrwren.wrenfam.com/blog/2010/03/04/linq-abuse-with-the-c-4-dynamic-type/comment-page-1/#comment-31267 Sat, 06 Mar 2010 13:53:30 +0000 http://jrwren.wrenfam.com/blog/2010/03/04/linq-abuse-with-the-c-4-dynamic-type/#comment-31267 @keith

because we don’t know if it will be IEnumerable. A more real example would be like this:

dynamic x = SomeDynamicResultFromPythonOrSomething();
object o = x;
var result = from i in o where … select …;

The method which returns a dynamic may or may not return a dynamic which ultimately implements IEnumerable. Further more, depending on my implementation of Where, Select, etc. I might not even care if they implement IEnumerable. It may be enough that it returns an object which implements GetEnumerator. Remember that foreach does not require a type implement IEnumerable, just that the GetEnumerator method exist.

]]>
By: Keith J. Farmer http://jrwren.wrenfam.com/blog/2010/03/04/linq-abuse-with-the-c-4-dynamic-type/comment-page-1/#comment-31266 Sat, 06 Mar 2010 04:12:46 +0000 http://jrwren.wrenfam.com/blog/2010/03/04/linq-abuse-with-the-c-4-dynamic-type/#comment-31266 Actually, instead of extending object, why not simply extend the non-generic IEnumerable. After all, you are making that presumption internally with Select.

]]>
By: Ayende Rahien http://jrwren.wrenfam.com/blog/2010/03/04/linq-abuse-with-the-c-4-dynamic-type/comment-page-1/#comment-31263 Fri, 05 Mar 2010 08:38:16 +0000 http://jrwren.wrenfam.com/blog/2010/03/04/linq-abuse-with-the-c-4-dynamic-type/#comment-31263 Never mind, got it to work.
Thanks, that actually solved my problem completely!

]]>
By: Ayende Rahien http://jrwren.wrenfam.com/blog/2010/03/04/linq-abuse-with-the-c-4-dynamic-type/comment-page-1/#comment-31262 Fri, 05 Mar 2010 08:30:20 +0000 http://jrwren.wrenfam.com/blog/2010/03/04/linq-abuse-with-the-c-4-dynamic-type/#comment-31262 Well, that is nice!
Can you make it work for SelectMany as well?
I tried a bit, but I couldn’t really get it to work

]]>