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??