Skip to content

Instantly share code, notes, and snippets.

@netsi1964
Created April 26, 2014 09:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save netsi1964/11315435 to your computer and use it in GitHub Desktop.
Save netsi1964/11315435 to your computer and use it in GitHub Desktop.
Dynamicweb Linq: three parts of linq query
@{
// 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