Skip to content

Instantly share code, notes, and snippets.

@netsi1964
Created April 26, 2014 10:05
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/11316315 to your computer and use it in GitHub Desktop.
Save netsi1964/11316315 to your computer and use it in GitHub Desktop.
Dynamicweb Linq: three parts of linq query - method-based query
@{
// 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