[LINQ] sql 에는 없는 키워드 - let
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
To introduce an identifier by using let
You can use the let keyword to introduce an identifier for any expression result in the query expression. This identifier can be a convenience, as in the following example, or it can enhance performance by storing the results of an expression so that it does not have to be calculated multiple times.
// studentQuery5 is an IEnumerable<string> // This query returns those students whose // first test score was higher than their // average score. var studentQuery5 = from student in students let totalScore = student.Scores[0] + student.Scores[1] + student.Scores[2] + student.Scores[3] where totalScore / 4 < student.Scores[0] select student.Last + " " + student.First; foreach (string s in studentQuery5) { Console.WriteLine(s); } // Output: // Omelchenko Svetlana // O'Donnell Claire // Mortensen Sven // Garcia Cesar // Fakhouri Fadi // Feng Hanying // Garcia Hugo // Adams Terry // Zabokritski Eugene // Tucker Michael
For more information, see let clause (C# Reference).
'Language > C#' 카테고리의 다른 글
프로그램 코딩 시 네이밍 규칙과 들여쓰기 (6) | 2015.05.15 |
---|---|
[C#] IEnumerable 과 IEnumerator 의 쓰임새 (191) | 2015.04.28 |
[LINQ] Basic LINQ Query Operations (C#) (6) | 2015.04.28 |
[LINQ] Element 로 어떤 동작 실행하는 경우 예제 (6) | 2015.04.28 |
[LINQ] 메모리상의 객체를 XML 로 변환하기 (671) | 2015.04.28 |