Skip to content

Commit 9440588

Browse files
author
shuxinqin
committed
fix bug #129.
1 parent fa24c89 commit 9440588

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Chloe/Query/Visitors/GeneralExpressionParser.cs

+12-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ DbExpression Process_MemberAccess_Which_Link_First_Or_FirstOrDefault(MemberExpre
203203

204204
Type delegateType = typeof(Func<,>).MakeGenericType(parameter.Type, selectorBody.Type);
205205
LambdaExpression selector = Expression.Lambda(delegateType, selectorBody, parameter);
206-
var selectMethod = methodCall.Object.Type.GetMethod("Select");
206+
207+
Type queryType = ConvertToIQueryType(methodCall.Object.Type);
208+
var selectMethod = queryType.GetMethod("Select");
207209
selectMethod = selectMethod.MakeGenericMethod(selectorBody.Type);
208210
var selectMethodCall = Expression.Call(methodCall.Object, selectMethod, Expression.Quote(selector)); /* query.Select(a=> a.xx.Name) */
209211

@@ -282,6 +284,15 @@ static bool IsIQueryType(Type type)
282284
implementedInterface = implementedInterface.GetGenericTypeDefinition();
283285
return queryType == implementedInterface;
284286
}
287+
static Type ConvertToIQueryType(Type type)
288+
{
289+
Type queryType = typeof(IQuery<>);
290+
if (queryType == type.GetGenericTypeDefinition())
291+
return type;
292+
293+
Type implementedInterface = type.GetInterface("IQuery`1");
294+
return implementedInterface;
295+
}
285296

286297
static bool IsComeFrom_First_Or_FirstOrDefault(MemberExpression exp)
287298
{

0 commit comments

Comments
 (0)