Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You are not limited of using LINQ's query syntax. You can also use the LINQ extension methods on the collections.</p> <p>The result that you'll receive will be strongly typed. Although anonymous types will be used when you do not return an existing type.</p> <p>The code below is C#, but you'll understand:</p> <pre><code>static void Main( string[] args ) { List&lt;Scan&gt; scans = new List&lt;Scan&gt; (); scans.Add (new Scan (new DateTime (2010, 1, 1), true, "Facility1")); scans.Add (new Scan (new DateTime (2010, 1, 1), true, "Facility2")); scans.Add (new Scan (new DateTime (2010, 1, 1), false, "Facility3")); scans.Add (new Scan (new DateTime (2010, 1, 26), true, "Facility1")); var result1 = scans.Where (s =&gt; s.Delivered).GroupBy (s =&gt; s.ScanDate); foreach( var r in result1 ) { Console.WriteLine (String.Format ("Number of delivered scans for {0}: {1}", r.Key, r.Count ())); } var result2 = scans.Where (s =&gt; s.Delivered).GroupBy (s =&gt; s.Facility); foreach( var r in result2 ) { Console.WriteLine (String.Format ("Number of delivered scans for {0}: {1}", r.Key, r.Count ())); } Console.ReadLine (); } </code></pre> <p>The result here is not really typed, since a GroupBy expression returns an IGrouping type. However, you can get around this, by doing this:</p> <pre><code> var result2 = scans.Where (s =&gt; s.Delivered) .GroupBy (s =&gt; s.Facility) .Select( s =&gt; new { Facility = s.Key, NumberOfItems = s.Count() } ); </code></pre> <p>Using the extension methods that LINQ provides, may perhaps help you understanding it a bit more.</p> <p>Sorry for the C# syntax, but I'm not really familiar with VB.NET.</p>
 

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