I have this class:
public class Presenter
{
public int? Society { get; set; }
public int? SenderCode { get; set; }
public string BusinessNameSender { get; set; }
public string AddressSender { get; set; }
public string VatNumberSender { get; set; }
public string Check { get; set; }
}
Retrieve the data with a query and with the ExtractField
method populate the Presenter
class
public static IEnumerable<Presenter> ExtractField(IEnumerable<dynamic> query)
{
return query.Select(x => new Presenter()
{
Society = x.ids.Society ?? null,
SenderCode = x.ids.SenderCode ?? null,
BusinessNameSender = x.details.Sender,
AddressSender = x.details.DestinationAddress,
VatNumberSender = x.details.VatNumberSender,
Check = x.ids.Check,
});
}
When I then use the ToList()
to then display the result on the screen within the list, the fields are sorted alphabetically, how do I make sure that the fields are seen in the order I have set?
I used dynamic because having two distinct queries but which have the same select seemed to me the best way not to duplicate code