You can create expressions dynamically, but not as simple as your pseudo-code - this requires reflection trees and expressions ( read this ).
An easy way to accomplish what you like is to short circuit the various parts of the predicate using boolean flags:
bool testMachineName;
bool testIsServer;
r = r.Where( x =>
( !testMachineName || iEnumerableMachineNames.Contains( x.Machine.Name ) ) ||
( !testIsServer || x.Server ) );
source
share