I have an API controller with method that returns a list. Method GetProjects returns List<(string, object)>
:
[HttpGet]
[Route("getProjects")]
public async Task<IEnumerable<(string, object)>> GetProjects(string departmentName)
{
var result = await dataService.GetProjects(departmentName);
return result.AsEnumerable();
}
Should the result be convert to IEnumerable
before returning it from API or can it be returning Task<List<(string, object)>>
?
Recommendations on .NET webpage are that List should not be returned from API:
dotnet standard design-guidelines guidelines-for-collections
What is a benefit of conversion List to IEnumerable in the above case?