tags:

views:

17

answers:

2

I have to tables, Table A is master, table B child.

What is the simplest LINQ2SQL Query to show all records from Table A exactly once that have at least a child in table B?

A: 
var q = (from record in database.records where record.children.Any()).Distinct();
Nick Allen - Tungle139
+1  A: 

Something like:

var AsWithBs = db.TableA.Where(x => x.Bs.Any())

or

var AsWithBs = from a in db.TableA
               where a.Bs.Any()
               select a;
Greg
thanks, works great, I think the where a.Bs.Any()is the clearest solution.
LINQ2SQLstarter