Lambda-Ausdruck mit <bool> und System.Nullable<bool>

Diese kann nicht kompilieren:

void Foo()
{
    using (var db = new BarDataContext(ConnectionString))
    {
        //baz is type 'bool'
        //bazNullable is type 'System.Nullable<bool>'
        var list = db.Bars.Where(p => p.baz && p.bazNullable); //Compiler: 
            //Cannot apply operator '&&' to operands of type
            //'System.Nullable<bool> and 'bool'
    }
}

Muss ich wirklich haben, um diese durch zwei Läufe, wo ich zuerst verwenden Sie die Bedingung, und führen Sie dann durch, die Liste mit den nullable-Bedingungen, oder gibt es eine bessere saubere glatte best-practice-Weg, dies zu tun?

InformationsquelleAutor radbyx | 2011-07-08
Schreibe einen Kommentar