private static MethodCallExpression CountDistinctExpression(ParameterExpression sourceParameter, LambdaExpression lambda) { MethodInfo selectMetodInfo = OeMethodInfoHelper.GetSelectMethodInfo(lambda.Parameters[0].Type, lambda.ReturnType); MethodCallExpression selectCall = Expression.Call(selectMetodInfo, sourceParameter, lambda); MethodInfo distinctMethodInfo = OeMethodInfoHelper.GetDistinctMethodInfo(lambda.ReturnType); MethodCallExpression distinctCall = Expression.Call(distinctMethodInfo, selectCall); MethodInfo countMethodInfo = OeMethodInfoHelper.GetCountMethodInfo(lambda.ReturnType); return(Expression.Call(countMethodInfo, distinctCall)); }