我最近购买了一个工具Linqer,它可以将SQL查询转换为LINQ,但它无法转换SqL的右或左连接。请解释一下如何使用SQL转换为Linq的右外连接?并且也是Linq支持别名,例如在此查询“tblaccounts as tb1”
中这是我的查询
SELECT ROW_NUMBER() OVER (ORDER BY MAIN.CHASSIS_NO asc) as S#, MAIN.CHASSIS_NO, MAIN.AVAILABILITY, MAIN.ID AS REF#, tblCar_Location.CAR_LOCATION AS LOCATION, MAIN.STOCK_TYPE, CONVERT(VARCHAR(10),
MAIN.purchasedate, 105) AS DATE,
CONVERT(VARCHAR(17), COST.TOTAL_COST, 1) AS TOTAL_COST,
SPEC.OPTIONS, CONVERT(VARCHAR(17), COST.O_P_YEN, 1)
AS O_P_YEN, CAST(MAIN.ID AS varchar(10)) AS ID2, MAIN.file_ref, PAPER.TEMP, SPEC.MODEL, SPEC.TRANSMISSION, tblcolor.color,
tblmake_details.model_description, tblmake.make, tblcompany.C_Code, CONVERT(VARCHAR(17), COST.Selling_Price, 1) AS SELLING_PRICE,
SPEC.make_category_ID, tblvehicle_category.CATEGORY, SPEC.FUEL_TYPE, MAIN.purchase_ref_ID, MAIN.ENTRY_DATE, MAIN.thirdParty_ID, tblaccounts.ACCOUNT,
MAIN.vendor_ID, tb1.ACCOUNT, tb1.field2 as contact_no, tb1.contactDetails as mobile_no,tb1.field1 as contact_address, CONVERT(VARCHAR(17),
COST.O_P, 1) AS O_P, CONVERT(VARCHAR(17), COST.O_P_rate, 1) AS O_P_rate,
(SELECT SUM(amount) AS Expr1
FROM tblexpense
WHERE (stock_ID = MAIN.ID) AND (Account_ID = 34)) AS CC_exp,
(SELECT SUM(amount) AS Expr1
FROM tblexpense AS tblexpense_1
WHERE (stock_ID = MAIN.ID) AND (Account_ID = 37)) AS ME_exp, MAIN.COMMENTS, DATEDIFF(day, MAIN.ENTRY_DATE, GETDATE()) AS Days_Over,
currency_master.currency_short_name,PAPER.CONSIGNMENT_NO AS CONT_NO,
purchase_ID,
CONVERT(VARCHAR(17), COST.fake_TOTAL_COST, 1) AS fake_TOTAL_COST
FROM currency_master RIGHT OUTER JOIN
COST ON currency_master.ID = COST.currency RIGHT OUTER JOIN
tblcompany RIGHT OUTER JOIN
tblaccounts RIGHT OUTER JOIN
MAIN LEFT OUTER JOIN
tblaccounts as tb1 ON MAIN.vendor_ID = tb1.ID ON tblaccounts.ID = MAIN.thirdParty_ID ON tblcompany.C_ID = MAIN.c_ID LEFT OUTER JOIN
tblCar_Location ON MAIN.LOCID = tblCar_Location.ID LEFT OUTER JOIN
tblcolor RIGHT OUTER JOIN
tblvehicle_category RIGHT OUTER JOIN
SPEC ON tblvehicle_category.category_ID = SPEC.make_category_ID LEFT OUTER JOIN
tblmake ON SPEC.make_ID = tblmake.make_ID LEFT OUTER JOIN
tblmake_details ON SPEC.model_description_ID = tblmake_details.ID ON tblcolor.color_id = SPEC.color_ID ON MAIN.ID = SPEC.ID ON
COST.ID = MAIN.ID LEFT OUTER JOIN
PAPER ON MAIN.ID = PAPER.ID
WHERE (MAIN.file_ref NOT LIKE 'J%') AND (MAIN.Po_Flag = 1) and MAIN.ISACTIVE=1