static void Main7() { string[] words = { "this", "is", "that", "is", "that", "those", "this", "that" }; var query = from w in words group w by w into wordgrup select wordgrup; foreach (var k in query) { Console.WriteLine(k.Key + " : " + k.Count()); } string str = "asbash hwejwewhewe"; var query1 = from c in str group c by c into gc select gc; foreach (var k in query1) { Console.WriteLine(k.Key + " : " + k.Count()); } var query2 = from e in Emp.GetEmps() group e by e.Dept into g select g; foreach (var d in query2) { Console.WriteLine(d.Key + " : " + d.Count() + " : "); } }
static void Main5() { var query = from e in Emp.GetEmps() orderby e.Dept descending select e; foreach (var e in query) { Console.WriteLine(e.FirstName + " " + e.LastName + " " + e.Salary + " " + e.Dept); } }
static void Main8() { var query = from e in Emp.GetEmps() from d in Dept.GetDepts() where e.Dept == d.DeptName select e; foreach (var e in query) { Console.WriteLine(e.FirstName + " " + e.LastName); } }
static void Main4() { var query = from e in Emp.GetEmps() select new Person { Name = e.FirstName + " " + e.LastName }; foreach (var p in query) { Console.WriteLine(p.Name); } }
static void Main6() { var query = from e in Emp.GetEmps() group e by e.Dept into deptGroup select deptGroup; foreach (var dept in query) { Console.WriteLine(dept.Key); foreach (var e in dept) { Console.WriteLine("\t" + e.FirstName + " " + e.LastName); } } }
static void Main17() { var query = from e in Emp.GetEmps() group e.Salary by e.Dept into deptGroup select deptGroup; foreach (var dept in query) { Console.WriteLine(dept.Key); foreach (var e in dept) { Console.WriteLine("\t" + e); } } }
protected void Page_Load(object sender, EventArgs e) { GridView1.DataSource = Emp.GetEmps(); GridView1.DataBind(); }