Query syntax trông giống SQL: var result = from x in list where x > 5 select x;.
- Method syntax dùng lambda expressions:
var result = list.Where(x => x > 5).Select(x => x);. - Cả hai đều tương đương về mặt chức năng — compiler chuyển query syntax thành method syntax nội bộ.
- Query syntax phù hợp cho join phức tạp; method syntax linh hoạt hơn cho các phép biến đổi chuỗi.
Query syntax resembles SQL: var result = from x in list where x > 5 select x;.
- Method syntax uses lambda expressions:
var result = list.Where(x => x > 5);. - Both are functionally equivalent — compilers transform query syntax to method syntax internally.
- Query syntax suits complex joins; method syntax offers more flexibility for chained transformations.