Delegates in queries

Nov 20, 2014 at 9:31 PM
I've run into an odd problem with delegates.

This works as expected:
var ldiUser = ldapContext.Query<LdapUserInfo>().FirstOrDefault(b => b.uid == "edhaswell");
While this does not work:
Func<LdapUserInfo, bool> whereCond = a => a.uid == "edhaswell"; 
ldiUser = ldapContext.Query<LdapUserInfo>().FirstOrDefault(whereCond);
The latter case goes into a search loop, in which it appears that the filter is not set, though it doesn't seem offhand that the receiving code should even know the difference.
Coordinator
Nov 21, 2014 at 10:06 AM
It has to be an Expression. Functions can't be visited to be turned into a request to send to the LDAP server.
Expression<Func<LdapUserInfo, bool>> whereCond = a => a.uid == "edhaswell"; 
Nov 21, 2014 at 2:35 PM
Of course. Thanks. Works like a charm!