var query = students.GroupBy(x => x.LastName)
.Select(g => g.FirstOrDefault())
//.OrderByDescending(x => x.LastName)
.Select(x => new { lastName = x.LastName, fName = x.FirstName });
var qqq = students.Select(s => s.LastName)
.Distinct()
.OrderByDescending(p => p)
.Select(p => new { RR = p });
var q = students.Where(x => x.LastName.Equals("Feng"));
var q1 = students.GroupBy((x => x.LastName));
Console.WriteLine("Group by a single property in an object:");
var query1 =
from s in students
group s by s.LastName into newGroup
orderby newGroup.Key
select newGroup;
foreach (var nameGroup in query1)
{
Console.WriteLine("Key: {0}", nameGroup.Key);
foreach (var student in nameGroup)
{
Console.WriteLine("\t{0}, {1}", student.LastName, student.FirstName);
}
}
.Select(g => g.FirstOrDefault())
//.OrderByDescending(x => x.LastName)
.Select(x => new { lastName = x.LastName, fName = x.FirstName });
var qqq = students.Select(s => s.LastName)
.Distinct()
.OrderByDescending(p => p)
.Select(p => new { RR = p });
var q = students.Where(x => x.LastName.Equals("Feng"));
var q1 = students.GroupBy((x => x.LastName));
Console.WriteLine("Group by a single property in an object:");
var query1 =
from s in students
group s by s.LastName into newGroup
orderby newGroup.Key
select newGroup;
foreach (var nameGroup in query1)
{
Console.WriteLine("Key: {0}", nameGroup.Key);
foreach (var student in nameGroup)
{
Console.WriteLine("\t{0}, {1}", student.LastName, student.FirstName);
}
}
No comments:
Post a Comment