ObservableCollection Data to CSV - Helpme solve Bug

In Progress Posted 6 years ago Paid on delivery
In Progress Paid on delivery

I'm using an ObservableCollection in my application; and I export that data to CSV. The export function works well ONLY the first time I export the data. The second time I export the data, the columns get different - but still exports.

I need you to fix that bug, and help export all the data in the collection in the same order the columns are originally.

Sample Code:

public static IEnumerable<string> ToCsv<T>(IEnumerable<T> list)

{

var fields = typeof(T).GetFields();

var properties = typeof(T).GetProperties().OrderBy(p=> "Time");

foreach (var @object in list)

{

yield return [url removed, login to view](",",

[url removed, login to view](x => ([url removed, login to view](@object) ?? [url removed, login to view]).ToString())

.Concat([url removed, login to view](p => ([url removed, login to view](@object, null) ?? [url removed, login to view]).ToString()))

.ToArray());

}

}

When I click Export Button:

using (var textWriter = [url removed, login to view](fileName))

{

string header = "Header Title Here"

[url removed, login to view](header);

foreach (var line in ToCsv([url removed, login to view] as ObservableCollection<[url removed, login to view]>))

{

[url removed, login to view](line);

}

}

C Programming Engineering Software Architecture Software Testing

Project ID: #16919168

About the project

6 proposals Remote project Active 6 years ago

Awarded to:

MoustafaS

Hello, I am an expert in c# and I can fix this for you within minutes. Available to do it now. Regards

$100 USD in 1 day
(19 Reviews)
4.8

6 freelancers are bidding on average $55 for this job

huongth

Hi. I am an expert in VBA, VBScript, Visual Basic, C#, F#, C, C++, ASM, Delphi, Java, iMacros, Flash, ASP, ASP.NET, Access, MySQL, MSSQL, QuickBooks, Oracle. I can create auto scripts to scrape websites, auto click, fo More

$30 USD in 1 day
(17 Reviews)
4.2
jboo7

A proposal has not yet been provided

$30 USD in 1 day
(24 Reviews)
4.4
gregorybliault

Can I see your code? I may have an idea for this, I want to check something and if it is working I will let you know! Please contact me

$35 USD in 1 day
(7 Reviews)
2.8
$111 USD in 1 day
(3 Reviews)
2.7