Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>try to use ObjectDumper project in the visual studio C# sample </p> <pre><code>using System; using System.Collections.Generic; using System.Linq; namespace testLinq { public class Record { public string ClassName {get;set;} public string Student {get;set;} public string Gender {get;set;} } class Program { public static void Main(string[] args) { Console.WriteLine("Hello World!"); Record[] list = new Record[] { new Record { ClassName="A" , Student="john" , Gender="male" }, new Record { ClassName="B" , Student="George" , Gender="male" }, new Record { ClassName="A" , Student="bill" , Gender="Female" }, new Record { ClassName="A" , Student="Steve" , Gender="male" } }; var result = list.GroupBy(x =&gt; x.ClassName).Select(x =&gt; new { k = x.Key, person = x}); ObjectDumper.Write(result, 1); Console.Write("Press any key to continue . . . "); Console.ReadKey(true); } } } </code></pre> <p>The output is</p> <pre><code>Hello World! k=A person=... person: ClassName=A Student=john Gender=male person: ClassName=A Student=bill Gender=Female person: ClassName=A Student=Steve Gender=male k=B person=... person: ClassName=B Student=George Gender=male Press any key to continue . . . </code></pre> <p>Example MVC code</p> <pre><code>public class YourViewModel { public YourViewModel() { Record[] list = new Record[] { new Record { ClassName="A" , Student="john" , Gender="male" }, new Record { ClassName="B" , Student="George" , Gender="male" }, new Record { ClassName="A" , Student="bill" , Gender="Female" }, new Record { ClassName="A" , Student="Steve" , Gender="male" } }; var result = list.GroupBy(x =&gt; x.ClassName).Select(x =&gt; new { k = x.Key, person = x}); using (var writer = new StringWriter()) { ObjectDumper.Write(result, 1 , writer); pivotString = writer.ToString(); } } private string pivotString; public string PivotTableText { get { return pivotString; } } } public static class YourHtmlExtension { public static string EncodedMultiLineText(this HtmlHelper helper, string text) { if (String.IsNullOrEmpty(text)) { return String.Empty; } return Regex.Replace(helper.Encode(text), Environment.NewLine, "&lt;br/&gt;") } } </code></pre> <p>In your controller</p> <pre><code> public ActionResult ReadPivotTable() { return View((new YourViewModel()); } </code></pre> <p>In your view </p> <pre><code>&lt;%= Html.EncodedMultiLineText(Model.PivotTableText) %&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload