Tengo el siguiente código:Lambda vs LINQ- "La expresión es siempre falsa"
var thing = (from t in things
where t.Type == 1 && t.IsActive
select t).SingleOrDefault();
if (thing == null)
{
// throw exception
}
things
es una colección de entidades Entidades marco de seguimiento automático
Esto funciona muy bien, sin embargo quiero usar una expresión Lambda lugar y cambió el LINQ a esto:
var thing = things.Select(t => t.Type == 1 && t.IsActive).SingleOrDefault();
Ahora ReSharper me está diciendo Expression is always false
para (thing == null)
.
¿Qué me he perdido?
impresionante. ¡muchas gracias! – Shevek