I want to convert linq expression into reflection.
exp1 = p2 => p2.s[new int[] { 14, 5 }].Select(
(item, index) => new { item, index }).Where(
x=>x.index > 2).Select(x => x.index).ToList();
I have converted the select part but having trouble in conversion of where part.
here i want to convert where(x=>x.index > 2) part of LINQ expression into reflection
This is how i converted select part:
var enumerableSelectIndexTSourceTResult = (from x in typeof(Enumerable).GetMethods()
where x.Name == "Select" && x.IsGenericMethod
let args = x.GetGenericArguments()
where args.Length == 2
let pars = x.GetParameters()
where pars.Length == 2 &&
pars[0].ParameterType == typeof(IEnumerable<>).MakeGenericType(args[0]) &&
pars[1].ParameterType == typeof(Func<,,>).MakeGenericType(args[0], typeof(int), args[1])
select x).Single();
Aucun commentaire:
Enregistrer un commentaire