I'm not sure exactly how to convert this SQL to LINQ:
LEFT JOIN pppltd.dbo.weboeordd ON pppltd.dbo.WEBOEORDD.ITEMNO = REPLACE(datawarehouse.dbo.ORDERFORMDUMP.ITEMNO,'-','') and weboeordd.ORDUNIQ = weboeordh.orduniq
This is the LINQ I have:
join weboeordd in db.WebOEOrdD on item.ITEMNO.Replace("-", "") equals weboeordd.ITEMNO && weboeordd.ORDUNIQ == db.WebOEOrdH.ORDUNIQ
The compiler is giving me an error on the right side of the " == " operator saying that "WebOEOrdH" doesn't have a definition for ORDUNIQ, but I know it does in the model.
UPDATE
Ivan Stoev has been kind enough to leave a link from MSDN on joins using composite keys
As a result, I've changed my LINQ to use anonymous types:
join weboeordd in db.WebOEOrdD on new { itemno = item.ITEMNO.Replace("-", ""), orduniq = weboeordh.ORDUNIQ } equals new { itemno = weboeordd.ITEMNO, orduniq = weboeordd.ORDUNIQ }
You should rather use equals
LINQ operator instead of ==
comparison operator. See MSDN for join clause (C# Reference)
Ivan Stoev has been kind enough to leave a link from MSDN on joins using composite keys
As a result, I've changed my LINQ to use anonymous types:
join weboeordd in db.WebOEOrdD on new { itemno = item.ITEMNO.Replace("-", ""), orduniq = weboeordh.ORDUNIQ } equals new { itemno = weboeordd.ITEMNO, orduniq = weboeordd.ORDUNIQ }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.