2016-11-09 64 views
-2
select 
    pm.GenerationID, srv.ServiceID, srv.ServiceName, srv.ServiceDescription, 
    srv.IsProPack, pm.MonthlyPrice, pm.AnnualPrice, ss.freeExpirationDate 
from 
    tbl_BILLING_PricingModels pm 
    inner join tbl_BILLING_Services srv on pm.ServiceID = srv.ServiceId 
    left join tbl_BILLING_SubscribedServices ss on srv.ServiceID = ss.ServiceId 
     and ss.ClientId='3B345E8B-3E6C-40E6-A4B8-E6371B717018' 
where 
    pm.GenerationID = 5 order by srv.ServiceID 

如何編寫linq查詢?如何在linq中用左連接寫sql查詢

回答

0

請注意,我沒有可能測試這一點,但如果它是不正確的,你可以按照這個方向:

var p = from pm in tbl_BILLING_PricingModels 
     join srv in tbl_BILLING_Services on pm.ServiceID equals srv.ServiceId nto res 
     from ss tbl_BILLING_SubscribedServices on srv.ServiceID = ss.ServiceId && ss.ClientId='3B345E8B-3E6C-40E6-A4B8-E6371B717018' 
     where pm.GenerationID = 5 
     order by srv.ServiceID 
     select new { pm.GenerationID, 
     srv.ServiceID, 
     srv.ServiceName, 
     srv.ServiceDescription, 
     srv.IsProPack }