LINQ All: it’s not all true

Pop quiz!

Will the program below throw an exception when executed?


using System;
using System.Collections.Generic;
using System.Linq;
class Review
{
public int Score { get; set; }
}
class Program
{
static void Main(string[] args)
{
var reviews = new List<Review>();
if (reviews.All(r => r.Score < 0))
throw new Exception("Alert manager");
}
}

Now try running it to see the result, you might be surprised 🙂

Not intuitive, now is it.

 

Advertisement
LINQ All: it’s not all true

SQL-92 ‘Til Infinity

Think you know SQL, then take this quick quiz at windowfunctions.com

It’s a lovely part quiz (10 questions), part tutorial experience, that will surely teach you a thing or two (or nine in my case, after the first question I was lost already)

If you’re anything like me, coming from a developer perspective, you can get your SQL-92 on, but anything a bit more smart or analytical gets complicated quickly.

You heard of  the OVER clause, but do your best to avoid needing it, right.
Or you think these SQL Server analytic functions and ranking functions have just been released. Well, this straightforward quiz made me finally “get” some of the basics and made the whole deal less intimidating, recommended.

Theme music for this blog post

SQL-92 ‘Til Infinity