0

如何将此 SQL 查询转换为 Entityframework 查询

SELECT DISTINCT
        EP.PrescriptionID
FROM    dbo.tEPPrescriptions EP 
WHERE   EP.CustomerID = 22
        OR ( EP.CustomerID IN (
             SELECT DISTINCT
                    AP.CustomerID
             FROM   dbo.tEPAdditionalPrescribers AP
                    INNER JOIN dbo.tAddresses A ON AP.SupervisorID = A.CustomerID
             WHERE  AP.SupervisorID = 22
                    AND AP.ActiveFlag = 1 )
             AND EP.LocationID IN (
             SELECT DISTINCT
                    AP.LocationID
             FROM   dbo.tEPAdditionalPrescribers AP
                    INNER JOIN dbo.tAddresses A ON AP.SupervisorID = A.CustomerID
             WHERE  AP.SupervisorID = 22
                    AND AP.ActiveFlag = 1 )
           )
4

1 回答 1

0

像下面这样的事情应该做

from epp in context.EPPrescriptions
where 
    epp.CustomerID == 22 || (
    (from epap in context.EPAdditionalPrescribers where epap.SupervisorID == 22 select epap.CustomerID).Contains(epp.CustomerID) &&
    (from ....)
)
select epp.PrescriptionID

希望这有帮助

顺便说一句:什么是 EPPrescription ?

于 2012-07-04T13:59:35.117 回答