Can't parse Select Linq with index parameter => Func<TSource, int, TResult>
Hello @StefH ,
I can't seem to get this one to parse. Could you help?
var TestExpression
= "Input.Lista.Where(x => x.Name != \"\").Select((item, index) => (item.Name.ToString(), index))";
ParameterExpression input = System.Linq.Expressions.Expression.Parameter(typeof(TemplateInput), "Input");
var result = System.Linq.Dynamic.Core.DynamicExpressionParser
.ParseLambda(new ParameterExpression[] { input }, null, TestExpression);
var lambdaCompile = result.Compile();
Basically trying to use this Select Signature:
public static IEnumerable<TResult> Select<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, int, TResult> selector);

Only the 'normal' Select is supported -> https://github.com/zzzprojects/System.Linq.Dynamic.Core/blob/master/src/System.Linq.Dynamic.Core/Parser/SupportedMethods/IQueryableSignatures.cs#L43
I'll take a look if in some way, your request can be implemented easily.
@StefH
Only the 'normal' Select is supported
Is this because in general Dynamic LINQ only supports lambda expressions with a single parameter? Or because this particular signature extends only on IEnumerable and not on IQueryable?
Only the 'normal' Select is supported -> https://github.com/zzzprojects/System.Linq.Dynamic.Core/blob/master/src/System.Linq.Dynamic.Core/Parser/SupportedMethods/IQueryableSignatures.cs#L43
I'll take a look if in some way, your request can be implemented easily.
I see thanks!
@stefH meanwhile do you know a way I could get the indexes of the elements in the collection that satisfies a certain condition using dynamic linq? Thanks again!
@zspitz : correct, only single lambda are supported. I'm looking at the code to see if this can be extended, however it seems diffucult.
@David-Moreira : not that I know, sorry
@StefH I understand, if it's possible, that'd be awesome. Both Where and Select have that second parameter just as the both those extensions in System.Linq
Thank you for your time! 👍