Skip to content

Commit 56b5b05

Browse files
authored
Merge pull request #245 from MichaelDenwood/master
Addressed Issue #243
2 parents 744a202 + b4c7249 commit 56b5b05

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Octokit.GraphQL.Core/Core/Builders/QueryEntityBuilders.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
using System;
2+
using System.Collections;
23
using System.Collections.Generic;
4+
using System.Linq;
35
using System.Linq.Expressions;
46
using System.Reflection;
7+
using Octokit.GraphQL.Core.Utilities;
58

69
namespace Octokit.GraphQL.Core.Builders
710
{
@@ -51,6 +54,26 @@ public static IQueryableValue<TValue> CreateMethodCall<TObject, TValue>(
5154
arguments));
5255
}
5356

57+
public static IEnumerable<TValue> CreateMethodCall<TObject, TValue>(
58+
this TObject o,
59+
Expression<Func<TObject, IEnumerable<TValue>>> selector)
60+
where TObject : IQueryableValue
61+
{
62+
var methodCall = (MethodCallExpression)selector.Body;
63+
var arguments = new List<ConstantExpression>();
64+
65+
foreach (MemberExpression arg in methodCall.Arguments)
66+
{
67+
var expression = (ConstantExpression)arg.Expression;
68+
var value = ((FieldInfo)arg.Member).GetValue(expression.Value);
69+
arguments.Add(Expression.Constant(value, arg.Type));
70+
}
71+
72+
return (IEnumerable<TValue>)(Expression.Call(Expression.Constant(o),
73+
methodCall.Method,
74+
arguments));
75+
}
76+
5477
public static TValue CreateMethodCall<TObject, TValue>(
5578
this TObject o,
5679
Expression<Func<TObject, TValue>> selector,

Octokit.GraphQL.Core/QueryableListExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static IDictionary<TKey, TElement> ToDictionary<TSource, TKey, TElement>(
7070
[MethodId(nameof(ToListMethod))]
7171
public static List<TValue> ToList<TValue>(this IQueryableList<TValue> source)
7272
{
73-
throw new NotImplementedException();
73+
return source.ToList<TValue>();
7474
}
7575

7676
public static ICompiledQuery<IEnumerable<T>> Compile<T>(this IQueryableList<T> expression)

0 commit comments

Comments
 (0)