Created
April 26, 2014 10:05
-
-
Save netsi1964/11316315 to your computer and use it in GitHub Desktop.
Dynamicweb Linq: three parts of linq query - method-based query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@{ | |
// The Three Parts of a LINQ Query: | |
// 1. Data source. | |
int[] numbers = new int[7] { 0, 1, 2, 3, 4, 5, 6 }; | |
string[] names = new string[7] {"Sten", "Anita", "Palle", "Helene", "Elisabeth", "Jan", "Mogens"}; | |
// 2. Method Query execution. | |
foreach (int num in numbers.Where((num, i) => num % 2 == 0).OrderBy(i => names[i])) | |
{ | |
@String.Format("{0} - ", names[num]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment