tags:

views:

77

answers:

1

Can someone explaing why existence of the following linq query...

(from e in db.Clients
        let
         log = (from f in db.CreditsafeLogs where f.Vat.Equals(e.VAT) orderby f.Sent descending select f).FirstOrDefault()
        where
         e.DeleteFlag.Equals("n") &&
         e.Active == true &&
         log != null &&
         log.Approved == false
        select e.Id)

compiles, but in runtime breaks the application (even though it's never called), while it's equivalent

Clients
   .Select (
      e => 
         new  
         {
            e = e, 
            log = CreditsafeLogs
               .Where (f => f.Vat.Equals (e.VAT))
               .OrderByDescending (f => f.Sent)
               .FirstOrDefault ()
         }
   )
   .Where (
      temp0 => 
            (((temp0.e.DeleteFlag.Equals ("n") && (temp0.e.Active == (Boolean?)True)) && 
                  (temp0.log != null)
               ) && 
               (temp0.log.Approved == False)
            )
   )
   .Select (temp0 => temp0.e.Id)

Works fine??

+1  A: 

Since we have no way of reproducing it, can you define "breaks the application"? Can you cite the error message please? For info, I have occasionally seen the expression compiler make dubious decisions about nullability - for more see here. This might be related, but impossible to say without the error message.

Marc Gravell
I'm using the flourinefx AMF gateway and the problem is that some "RPC methods" stops works (or can't be found by flourine).
Niels Bosma
Unfortunately, I still don't think that is enough detail to even begin to answer this...
Marc Gravell