开发者

LINQ Show every Record from table A exactly once when it exists at least once in Table B

开发者 https://www.devze.com 2022-12-22 12:53 出处:网络
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

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?


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;


var q = (from record in database.records where record.children.Any()).Distinct();
0

精彩评论

暂无评论...
验证码 换一张
取 消