[英]How to make linq lambda expression
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 });
希望能幫助到你
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.