I have a method with the following signature:
void Method(Expression<Func<TSource, IEnumerable<TCollection>>> collectionSelector) {}
I need to get the result value of collectionSelector
in order to compare the result with another instance of IEnumerable<TCollection>
. I'm trying to achieve my objective as in the code below, but I got stuck while I was asked to provide parameter value:
var collectionSelectorFunc = collectionSelector.Compile();
var collection = collectionSelectorFunc.Invoke(collectionSelector.Parameters[0]./*???*/);
How to put there the actual value of the parameter?
There is no value because a parameter is a placeholder. A parameter represents a method argument (lambda argument in this case). You can call this function/expression with any value. There is no pre-set value.