I'm trying to repair some code that I cloned from a public repo. It's an async
method that's missing an await
operator:
public async Task<IEnumerable<JsonPatchOperation>> GetRemoveAllRelationsOperations(IBatchMigrationContext batchContext, WorkItem targetWorkItem)
{
return targetWorkItem.Relations?.Select((r, index) => MigrationHelpers.GetRelationRemoveOperation(index));
}
I'm trying this:
public async Task<IEnumerable<JsonPatchOperation>> GetRemoveAllRelationsOperations(IBatchMigrationContext batchContext, WorkItem targetWorkItem)
{
return await Task.Run(o => targetWorkItem.Relations?.Select((r, index) => MigrationHelpers.GetRelationRemoveOperation(index)));
}
...but I'm getting an error in the IDE:
Delegate 'Action' does not take 1 arguments
I found some similar discussions, but unfortunately none of them quite address the lambda syntax:
- Delegate System.Action does not take 1 arguments
- Delegate System.Action<dynamic,int> does not take `1' arguments
- Delegate `System.Func<bool>' does not take `1' arguments
- Delegate Action does not take 3 arguments
It appears the precompiler is interpreting the input as an Action
when it should be seeing it as a Func
instead. But I thought that the statement o => ...
could indicate either.
I'm not familiar enough with C# to be able to work this one out. Can someone assist?
How do I tell the precompiler that I want to send a Func
instead of an Action
?