score:7
var x = gigs.where(g=>g.acts.select(a=>a.id).contains(7));
these two queries also return the same:
var x = gigs.where(g=>g.acts.count(a=>a.id == 7) > 0);
var x = gigs.where(g=>g.acts.firstordefault(a=>a.id == 7) != null);
score:14
essentially the same as mike_g, only more verbose syntax and using equality.
var mycollection = from gig in qry
where gig.acts.any(act => act.id == 7)
select gig;
just an edit to bring comments to the answer:
actually query is for an id on a member (artist) on the act object that can be null.
new query:
var mycollection = from gig in qry
where gig.acts.any(act => (null != act.artist) && (act.artist.id == 7))
select gig;
Source: stackoverflow.com
Related Query
- Querying Child Collections in LINQ
- Querying Child Collections 2 levels deep in LINQ
- linq question: querying nested collections
- LINQ Source Code Available
- Querying xml child elements with prefixed namespace using LINQ to XML
- How to filter child collections in Linq
- creating Linq to sqlite dbml from DbLinq source code
- Querying two collections at same time with Linq
- Sorting Multiple Levels of Child Collections with LINQ to Entities
- source code for LINQ 101 samples
- Linq issues querying two Collections of data
- Create a tree structure in linq with a single list source with parent - child as strings of an object
- Using LINQ To Select Records Based on Child Collections item
- c# Linq or code to extract groups from a single list of source data
- Querying external data source with LINQ
- Linq query to fill ViewModel collection including child ViewModel collections
- Linq querying local collections against database
- Querying the database using EF Code First and Linq
- Retrieving information from derived child object collections using LINQ
- Convert string[] to int[] in one line of code using LINQ
- Code equivalent to the 'let' keyword in chained LINQ extension method calls
- LINQ Ring: Any() vs Contains() for Huge Collections
- Linq code to select one item
- Querying DataColumnCollection with LINQ
- How to use LINQ with dynamic collections
- How are people unit testing code that uses Linq to SQL
- How to merge a collection of collections in Linq
- How to include() nested child entity in linq
- How do you construct a LINQ to Entities query to load child objects directly, instead of calling a Reference property or Load()
- How to order child collections of entities in EF
More Query from same tag
- Grouping data with datatable with ASP.NET
- Filter List<objet1> by using another List<objet2>
- List.Except except with property of custom class
- Select Clause In LINQ Query
- Long process method with LINQ Query should be in Queue
- How to edit DataGridView and send change back to Entity (LINQ)
- ERROR: IDENTITY_INSERT is set to OFF
- C# Remove duplicates from two lists with multiple properties
- How to use ToString() method to convert an integer to string inside LINQ
- Get column name by value of field in datarow
- How do I eager load a grandparent record in EF 4.1
- How to create a comma delimited string from distinct list of values using LINQ?
- wpf - C#: Log In and Log Out History
- Distinct of Enumerable.Select of nested List in C#
- Filtering Comma Separated Data
- Getting common values in two array issue using LINQ
- Why doesn't array of elements return from xml?
- Get all unique variations
- What is the easiest way to seeing if there are any matches across a few DateTime arrays?
- Linq filter parent objects based on child objects collection
- Is there a better way to do this, maybe replace the for/foreach loop with something LINQ ish?
- how to read the last inserted field with linq
- How to convert List<String> to Dictionary<int,String>
- how will this linq query execute
- Compare two lists for Max value within a parameter using linq
- Order by with Collate clause | Entity Framework
- C# linq group by on different keys in the same entity
- C# merge multiple lists based on timestamp
- Using Linq to read from multiple tables
- ef code first: get entity table name without dataannotations