-2

How do I write this in linq:

SELECT
    c.customerNumber,
    IsNull(l.loanNumber, '') AS loanNumber,
    dd.documentTypeName,
    dd.documentSubTypeName,
    d.filename,
    (SELECT propertyId FROM SystemProperties WHERE propertyKey LIKE 'acculoan.inputType.Other') AS inputType
FROM
    document AS d INNER JOIN qryDocumentDefinitions AS dd
        ON d.documentDefId = dd.documentDefId
        AND d.documentId =  @DocumentId
    INNER JOIN customer AS c
        ON c.customerId = d.customerId
    LEFT OUTER JOIN loan AS l
        ON l.loanId=d.loanId

Help needed with the isnull especially and the nested select.

Many thanks in advance..!

neojakey
  • 1,633
  • 4
  • 24
  • 36

1 Answers1

0

You can try the below (have not been able to test, maybe will require some adjustments, but should be in the same form);

from Doc in db.document 
join DocDef in db.qryDocumentDefinitions on doc.documentDefId equals DocDef.documentDefId 
join Cus in db.Customer on Cus.customerId = Doc.customerId
from loan in db.loan 
     .Where(loan => loan.loanId == Doc.loanId).DefaultIfEmpty()
select new
    {
         CustNo= Cus.customerNumber
        ,loan == null ? "" : loan.loanNumber
        ,DocType= DocDef.documentTypeName
        ,DocSubType= DocDef.documentSubTypeName
        ,filename = Doc.filename
        ,inputType = (?int)(from Sys in db.SystemProperties 
                              where Sys.propertyKey.Contains("acculoan.inputType.Other")
    }
Nadeem_MK
  • 7,533
  • 7
  • 50
  • 61