It should be something like this (Use SelectMany
and Count
methods):
int c = elements.SelectMany(e => e.Attributes)
.Count(a => a.Name == "City" && a.GetValue().ToString() == "Oakland");
More Related Contents:
- Linq: help me to make this work
- When to use .First and when to use .FirstOrDefault with LINQ?
- printing all contents of array in C#
- How do I apply OrderBy on an IQueryable using a string column name within a generic extension method?
- What guarantees are there on the run-time complexity (Big-O) of LINQ methods?
- Convert string[] to int[] in one line of code using LINQ
- LINQ – Left Join, Group By, and Count
- Func with out parameter
- How to get the index of an element in an IEnumerable?
- LINQ: Not Any vs All Don’t
- How to check if IEnumerable is null or empty?
- What is the Efficiency and Performance of LINQ and Lambda Expression in .Net?
- LINQ Inner-Join vs Left-Join
- Why is LINQ .Where(predicate).First() faster than .First(predicate)?
- DISTINCT() and ORDERBY issue
- High memory consumption with Enumerable.Range?
- How to Get XML Node from XDocument
- Can I LINQ a JSON?
- Use linq to generate direct update without select
- Find substring in a list of strings
- Get List element position in c# using LINQ
- Linq – What is the quickest way to find out deferred execution or not?
- Linq style “For Each” [duplicate]
- How to sort a dictionary by key
- Issues Doing a String Comparison in LINQ
- Expressing recursion in LINQ
- C# Searching for files and folders except in certain folders
- Linq where column == (null reference) not the same as column == null
- Does “foreach” cause repeated Linq execution?
- Can I use Linq’s Except() with a lambda expression comparer?