I'm working on a Powershell module that needs to call a .NET method which accepts a string list parameter. The method constructs a REST URL based on the string collection to retrieve the results for all elements in the list in a single API call:

```cs
var MyAPIConnector = new APIConnector();
var elements = File.ReadAllLines(@"C:\temp\myfile.txt").ToList();
List<ApiResult> Result = MyAPIConnector.GetResult(elements);

```

This code executes within a couple of seconds.

In my Powershell module, the same operation takes a lot longer. Here's how the module is coded:

```cs
[Cmdlet(VerbsCommon.Get, "ApiResult")]
[OutputType(typeof(ApiResult))]
public class GetApiResults : Cmdlet
{
    [Parameter(Mandatory = true, ValueFromPipeline = true)]
    public string[] Identity {get; set;}

    private List<string> Input;
    private List<ApiResult> Result;

    protected override void BeginProcessing()
    {
        base.BeginProcessing();
    }

    protected override void ProcessRecord()
    {
        base.ProcessRecord();
        Result = MyAPIConnector.GetResult(Identity.ToList());
        WriteObject(Result);
    }
}

```

If I use my Cmdlet in the same maner as my sample program:

```
$Result = Get-Content -Path 'C:\temp\myfile.txt' | Get-ApiResult

```

The same result is returned, but it is much, much slower. Through debugging, I was able to determine that although, in my Cmdlet source code, I am using Linq to convert the string array Identity to a List, MyAPIConnector.GetResult() is being called separately for each element of the array! Can anyone explain why that is?