Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LINQ
- var innerGroupJoinQuery2 =
- from category in categories
- join prod in products on category.ID equals prod.CategoryID into prodGroup
- from prod2 in prodGroup
- where prod2.UnitPrice > 2.50M
- select prod2;
- var someCollection = students
- .Where(st => st.Id > 1)
- .OrderBy(st => st.Name)
- .ThenBy(st => st.Courses.Count)
- .Select(st => new
- {
- Name = st.Name,
- Courses = st.Courses.Count
- })
- .ToArray();
- var projectedItems = students.Select(st => new Student { Name = st.Id.ToString(), Courses = new List<Course>() });
- var ordered = students.OrderBy(st => st.Courses.Count).ThenBy(st => st.Name);
- int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
- var querySmallNums =
- from num in numbers
- where num < 5
- select num;
- public static IEnumerable<Tuple<string, double>> AverageAge(Animal[] animals) //Get every kind of animal in separate group and calculate average
- {
- var averageAges =
- from animal in animals
- group animal by animal.GetType() into animalType
- select new Tuple<string, double>(animalType.Key.Name, animalType.Average(a => a.Age));
- return averageAges;
- }
Advertisement
Add Comment
Please, Sign In to add comment