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:
Post a Comment