不知道有沒有人可以迅速幫助我把這個SQL轉為Linq。我需要一點幫助,然后我就可以從中學習了。
SELECT raoe.AreaofExpID
, aoe.ServiceLineID
, raoe.ResponseID
FROM AreaofExp aoe
INNER[/span
JOIN ResponseAreaOfExp raoe
ON aoe.AreaofExpID = raoe.AreaofExpID
INNER
JOIN Response resp
ON raoe.responseid = resp.responseid
AND resp.segmentid = 4;
經過努力,我得到了這樣的結果:
var query = from aoe in _cctDBContext.AreaOfExp
join raoe in _cctDBContext.ResponseAreaOfExp on aoe.AreaofExpId equals raoe.AreaofExpId
join resp in _cctDBContext.Response on raoe.ResponseId equals resp.ResponseId
選擇 新
{
raoe.AreaofExp,
aoe.ServiceLineId,
raoe.ResponseId
};
而現在我得到了一個錯誤。預期的背景關系關鍵字'on'
。
我相信我的第二個連接是錯誤的,但我不確定怎么做。
uj5u.com熱心網友回復:
以下是我寫的代碼,在沒有修改的情況下,讓你的查詢作業:
我寫的代碼是為了讓你的查詢作業,不需要修改。
public static class _cctDBContext<
{
public static List<AreaOfExp> AreaOfExp = new List<AreaOfExp> ();
public static List<ResponseAreaOfExp> ResponseAreaOfExp = new Listlt; ResponseAreaOfExp> ();
public static List<Response> Response = new List< Response> ();
}
public class AreaOfExp
{
public int AreaofExpId;
public int ServiceLineId;
}
public class ResponseAreaOfExp
{
public int AreaofExpId;
public int AreaofExp;
public int ResponseId;
}
public class Response public int ResponseId;
換句話說,你在問題中發布的查詢是好的,不包含錯誤。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/310050.html
標籤:
