Skip to content

Commit

Permalink
Fix diegose#1 - smarter "SelectMany" search.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCloudlessSky committed Aug 15, 2013
1 parent 13a3c4c commit 0dd8547
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion CollectionQuery/CollectionQueryableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,16 @@ private static SelectManyFunc CreateSelectManyGetter(Tuple<Type, Type> types)
var itemType = types.Item2;

var selectManyMethod = typeof(Queryable).GetMethods()
.First(x => x.Name == "SelectMany")
.First(m =>
{
var parameters = m.GetParameters();
if (m.Name != "SelectMany" || parameters.Length != 2) return false;

var p1 = parameters[1].ParameterType;

return p1.GetGenericTypeDefinition() == typeof(Expression<>)
&& p1.GetGenericArguments()[0].GetGenericTypeDefinition() == typeof(Func<,>);
})
.MakeGenericMethod(ownerType, itemType);

var ownerQueryableParameter = Expression.Parameter(typeof(object));
Expand Down

0 comments on commit 0dd8547

Please sign in to comment.