Created
April 26, 2014 09:11
-
-
Save netsi1964/11315435 to your computer and use it in GitHub Desktop.
Dynamicweb Linq: three parts of linq 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 }; | |
// 2. Query creation. | |
// numQuery is an IEnumerable<int> | |
var numQuery = | |
from num in numbers | |
where (num % 2) == 0 | |
select num; | |
// 3. Query execution. | |
foreach (int num in numQuery) | |
{ | |
@String.Format("{0,1} ", num); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment