Home

Anonymous type values in grid view

I would like to create a csv file and used an ArrayList of anonymous types to get the best results.
Dumping the results works fine in the Rich Text view but when I switch to grid view (to see past a 1000 results) then I see one column named "Value" and each row in an "Anonymous" link to the real values. What happened to the real data that shows fine in the Rich Text view?

Comments

  • I was pretty sure LINQPad beta had a DumpCsv() method. But now I can't find it.
    You can set the max number of lines in edit->preferences.
  • It seems as the maximum maximum is 10000 lines.
    And I've noticed that the resolving of anonymous types in grid view stops somewhere above 540000 lines.

    I know that it would be much better to generate this right into csv but I was too lazy to look up the right method. :) Now it seems I'll really have to resort to the proper solution.
  • Use Util.WriteCsv:

    Util.WriteCsv (myData, @"c:\temp\foo.csv");
  • Excellent, my last problem was that I used ArrayList with anonymous types out of laziness, but I converted it to List with ExpandoObjects inside that I cast into anonymous types with a select for the WriteCsv to work. This way I can keep the script as C# statements as I don't have to define a struct. (having said that I could have used tuples but this is much nicer as it has property names)

    Thanks!
  • Great. Regarding the incorrect rendering of an ArrayList of anonymous types, I cannot reproduce this. The following renders fine for me in both rich text and data grids mode:
    new ArrayList (new[] 
    {
    	new { X = 1, Y = 2 },
    	new { X = 1, Y = 2 }
    })
  • edited August 2013
    As I said it only happens with very large lists. Try this:
    var list = new ArrayList();
    for (int i = 0; i < 600000; i++)
    {
      list.Add( new { X=1, Y=2});
    }
    list.Dump();
    
    It does work with 500000 but not with 600000 (in data grid mode).
    I of course realise that it was probably not meant for this...
  • FYI, I've fixed the latest beta so you'll always get proper columns in grid mode, regardless of result set size.
Sign In or Register to comment.