从孙子孙选择价值 [英] Select value from grandchildren
本文介绍了从孙子孙选择价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下表格结构:
我想选择:
- 所有TableA条目+表C中的标识符列具有:
- TableBType(TableBTypeValue)中的特殊值
- 一个特殊值在TableCType(TableCTypeValue)
我的问题是当有没有TableB条目的TableA条目或没有TableC的TableB条目时,linq查询似乎失败(TableBType和TableCType是强制性的,因此它们没有这个问题)。
The problem that I have is that the linq queries seem to fail when there are TableA entries that have no TableB entry or if there are TableB entries without a TableC (TableBType and TableCType is mandatory so they don't have that problem).
使用SQL这不是一个大问题,但是因为我是linq的新手,我找不到正确的方式来创建这个查询。
With SQL this would not be a big problem, but as I am new to linq I could not find the correct way to create this query.
推荐答案
我认为这是你正在寻找的:
I think this is what you are looking for:
from c in db.TableC where c.TableCType == TableCTypeValue join b in db.TableB on c.TableBId equals b.Id where b.TableBType == TableBTypeValue join a in db.TableA on b.TableAId equals a.Id select new { a, c.Identifier };
希望有帮助。
这篇关于从孙子孙选择价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文