SelectMany or multiple from

SelectMany method doesn't exist as query keyword and it's used to flatten resulting sequence into single sequence. For example let's select titles of all employees younger as 50 years.
MySqlConnection conn = new MySqlConnection("SERVER=localhost; DATABASE=employees;UID=root;PASSWORD=");
var emp = new EmployeeDataContext(conn);
emp.Log = Console.Out;

var results = from e in emp.Employees
            where e.BirthDate > DateTime.Now.AddYears(-50)
            select e.Titles;

foreach (var a in results)
    Console.WriteLine(a);

Listing 11.1

The result will contain arrays of Titles and we need just list of titles. An additional from select keyword paar help us to retrieve flat titles.
MySqlConnection conn = new MySqlConnection("SERVER=localhost; DATABASE=employees;UID=root;PASSWORD=");
var emp = new EmployeeDataContext(conn);
emp.Log = Console.Out;

var results = from e in emp.Employees
            where e.BirthDate > DateTime.Now.AddYears(-50)
            from t in e.Titles
            select t.Title1;

foreach (var a in results)
    Console.WriteLine(a);

Listing 11.2

No comments:

HOWTO: Repair Logitech M325 Mouse

FixIt says that you will find single screw under CE label. It isn't always true.