Ví dụ:Tôi có thực sự cần sử dụng AsQueryable() trên bộ sưu tập không? đang
List<Student> Students = new List<Student>()
{
new Student(101, "Hugo", "Garcia", new List<int>() { 91, 88, 76, 93 }),
new Student(102, "Rick", "Adams", new List<int>() { 70, 73, 66, 90 }),
new Student(103, "Michael", "Tucker", new List<int>() { 73, 80, 75, 88 }),
new Student(104, "Fadi", "Fakhouri", new List<int>() { 82, 75, 66, 84 }),
new Student(105, "Peter", "Barrows", new List<int>() { 67, 78, 70, 82 })
};
var query = from student in Students
where student.Marks.AsQueryable().All(m => m > 70)
select student;
foreach (Student student in query)
{
Console.WriteLine("{0} {1}<br />", student.FirstName, student.LastName);
}
Nhưng nếu tôi thay đổi truy vấn để
var query = from student in Students
where student.Marks.All(m => m > 70)
select student;
này cũng làm việc và tạo ra kết quả tương tự, vì vậy có gì khác biệt?
Câu hỏi tương tự về ['AsEnumerable'] (http://stackoverflow.com/questions/3389855/am-i-misunderstanding-linq-to-sql-asenumerable) – nawfal