Click here to Skip to main content
       

LINQ

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionThe type of one of the expressions in the join clause is incorrect. Type inference failed in the call to GroupJoinmemberdotnet9516 Oct '12 - 14:28 
select a.LoanNum, PromiseAmt, isnull(SUM(PdAmt), 0) as PostedAmt
 from LoanPromises a with(nolock)
 left outer join LoanPayment lp with(nolock) on a.LoanNum = lp.LoanNum and a.PromiseDt < lp.PmtPostDt
 group by a.LoanNum, PromiseAmt
 having isnull(Sum(PdAmt),0) < PromiseAmt
 
Here is my linq query
 
var query = from pmts in oLoan.LoanPayments
     join promise in oLoan.LoanPromiseToPays
    on new { p1 = pmts.LoanNum, p2 = pmts.PmtPostDt} equals new {LoanNum = promise.LoanNum, PmtPostDt = promise.PromiseDt } into outer
 from defaulted in outer.DefaultIfEmpty()
 group defaulted by promise.LoanNum && promise.PromiseAmt into grouped
 select new
 {
    LoanNum = grouped.Key,
    Sum = grouped.Sum(t => t.PdAmt < t.PromiseAmt),
    PmtPostDt = promise.PromiseDt ?? default(DateTime)
 }
 

AnswerRe: The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to GroupJoinmemberRichard Deeming22 Oct '12 - 2:19 
Try taking out the p1 = and p2 = from the LHS of your join.
 
At the moment, you have:
on new { p1 = ..., p2 = ...} equals new { LoanNum = ..., PmtPostDt = ... }
The compiler has no way to map one key to the other, since the property names are different.
 
Also, your LINQ join won't match your SQL join. The SQL has promise.PromiseDate < payment.PmtPostDt, but your LINQ query has promise.PromiseDate = payment.PmtPostDt instead.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 3 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid