我使用linq查询加入3个表我想将其更改为使用lambda?
var listOFValue = (from form in db.Forms
join control in db.Controls on form.RecordId equals control.FormId
join values in db.Values on control.RecordId equals values.ControlId
where form.RecordId == formId && control.RecordId == fieldId
orderby values.Name ascending
select values).ToList();
return listOFValue;
答案 0 :(得分:0)
像这样:
var listOFValue = (db.Forms.Join(db.Controls, form => form.RecordId, control => control.FormId,
(form, control) => new {form, control})
.Join(db.Values, @t => control.RecordId, values => values.ControlId, (@t, values) => new {@t, values})
.Where(@t => form.RecordId == formId && control.RecordId == fieldId)
.OrderBy(@t => values.Name)
.Select(@t => values)).ToList();