Skip to content

Csv output formatter fails when Linq chain #198

Open
@twsouthwick

Description

@twsouthwick

I am using v3.0.0 of the Csv output formatter. However, I saw the following issue:

[Route("a")]
[HttpGet]
[Produces("text/csv")]
public IEnumerable<A> GetA()
{
    var b = new[]
    {
        new B { Item2 = "Hello" },
    };
    var result = b.Select(i => new A { Item1 = i.Item2 });

    return result;

    // If I replace the return with the following it works as expected:
    // return result.ToList();
}

public class A
{
    public string Item1 { get; set; }
}

private class B
{
    public string Item2 { get; set; }
}

The result of this is:

Item2
Hello

when I would expect

Item1
Hello

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions