我已經使用「查詢語法」加入數據表,它工作正常。任何人都可以幫助將它轉換爲lamba語句嗎?如何在C#中使用labda表達式linq內聯數據表?
var oVarLoanDetails = (from data in ActiveReferralDetails.AsEnumerable()
join reftypedata in ActionType.AsEnumerable()
on data.Field<int>("atid") equals reftypedata.Field<int>("atid")
join refsubtypedata in ActionSubType.AsEnumerable()
on data.Field<int>("ASTID") equals refsubtypedata.Field<int>("ASTID")
where reftypedata.Field<int>("atid") == refsubtypedata.Field<int>("atid")
select new LoanDataInfo
{
LoanNumber = data.Field<string>("Loanno").ToLower(),
ATID = reftypedata.Field<int>("atid"),
RefType = reftypedata.Field<string>("ATSHORTDESC"),
RefSubType = refsubtypedata.Field<string>("SUBTYPESHORTDESC")
});
//Class LoanDataInfo
public class LoanDataInfo
{
public string LoanNumber { get; set; }
public int ATID { get; set; }
public string RefType { get; set; }
public string RefSubType { get; set; }
}
爲什麼你想這樣做?在連接中使用方法語法非常難看,我從不記得我要傳遞什麼,難怪你需要問。你總是可以混合兩種語法來避免它。 –
是的,即使我同意lamda加入是醜陋的。我只想嘗試在數據表中寫入lamda連接.... –
theres沒有任何好處 –