ServiceStack - dictionary for csv


In my project I use ServiceStack to allow user to export data in csv format. It's ServiceStack that makes the job but it always sorts my dictionary by alphabetical and I don't want that. I want that my csv file have his columns in exact order that I inserted my data in the dictionary.

There is a way to configure ServiceStack to don't make this sort ?

My dictionary :

var excelResult = new Dictionary<string, string>();            

                    excelResult["Id"] = x.Id.ToString();
                    excelResult["IBS Account Id"] = x.IBSAccountId.ToString(CultureInfo.InvariantCulture);
                    excelResult["IBS Order Id"] = x.IBSOrderId.ToString();

And in my csv file, instead of "Id, IBS Account Id,IBS Order Id" I have "IBS Account Id,IBS Order Id,Id"

Thank you very much !!

Here is how to unregister the default 'text/csv' content-type and serializer.

In AppHost.cs,

using ServiceStack.Common;

In AppHost Configure()...

SetConfig(new EndpointHostConfig
    EnableFeatures = Feature.All.Remove(Feature.Csv),

Your apphost will no longer do any special handling for text/csv. At that point, you should be able to register it again as you wish, as explained in How to register your own custom format with ServiceStack.

Substitute your TapasSerializer for CsvSerializer and you should be good.

I discovered a clue how to do it from this SO answer.