c# - 如何制作 linq lambda 表达式
问题描述
select a.ObjectFieldID,
a.FieldName,
b.RelationName
from tblMNG_Framework_ObjectField as a left join
tblMNG_Framework_ObjectRelation as b on a.ObjectID = b.RelatedObjectID
and a.ObjectFieldID = b.RelatedKeyFieldID
where a.ObjectID = 2
and a.Deleted = 0
解决方案
这是我的快速代码,我没有要测试的数据,所以如果左连接不准确,请向我反馈您的数据样本。
tblMNG_Framework_ObjectField.GroupJoin(tblMNG_Framework_ObjectRelation,
a => new { JoinCol1 = a.ObjectID, JoinCol2 = a.ObjectFieldID },
b => new { JoinCol1 = b.RelatedObjectID, JoinCol2 = b.RelatedKeyFieldID },
(a, b) => new { a, b }).Where(x => x.a.ObjectID == 2 && x.a.Deleted == 0)
.SelectMany(b => b.b.DefaultIfEmpty(),
(a, b) => new { a.a.ObjectID, a.a.FieldName, b.RelationName });
希望能帮助到你
推荐阅读
- swiftui - SwiftUI: How to constrain image size?
- java - Lcom/google/firebase/FirebaseApp 类中没有虚拟方法 setTokenProvider(Lcom/google/firebase/internal/InternalTokenProvider;)V
- nim-lang - 为什么显式指定泛型类型的 proc 不起作用?
- r - 由于 dplyr 函数参数中的非标准表达式,R 包失败 R CMD 检查
- reactjs - 世博包APK/IPA包过大
- python - (VS Code)Pylint 在导入模块时抛出语法错误,但在我运行代码时工作得很好
- c# - Task.Run 是否能够在后台运行冗长的代码?
- pandas - 合并数据帧时的 KeyError(key)
- heroku - Heroku 无法使用 gamedig 节点模块
- git - Gitlab 存储库镜像到 Github