You can filter the field number(tolerance fields are public). And then filter the field otherNumberif a is of type B. Otherwise, the second filtering will simply skip
list.Where(a => a.number > 5).Where(a => !(a is B) || ((B)a).otherNumber > 7)
Perhaps a more readable way:
list.Where(a => {
var b = a as B;
return a.number > 5 && (b == null || b.otherNumber > 7);
})
Or query syntax
from a in list
let b = a as B
where a.number > 5 && (b == null || b.otherNumber > 7)