ObservableCollection Data to CSV - Helpme solve Bug

进行中 已发布的 6 年前 货到付款
进行中 货到付款

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 编程 工程 软件构架 软件测试

项目ID: #16919168

关于项目

6个方案 远程项目 活跃的6 年前

授予:

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 在1天内
(19条评论)
4.8

有6名威客正在参与此工作的竞标,均价$55/小时

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 更多

$30USD 在1天里
(17条评论)
4.2
jboo7

A proposal has not yet been provided

$30USD 在1天里
(24条评论)
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

$35USD 在1天里
(7条评论)
2.8
$111USD 在1天里
(3条评论)
2.7