I have defined a specification as an object of type Expression<Func<User, bool>>
like this:
public static Expression<Func<User, bool>> IsSystemUser
{
get
{
return user => user.UserID == -1;
}
}
This works marvellously with queries written in extension method syntax:
return workspace.GetDataSource<User>().Where(UserSpecifications.IsSystemUser);
But not with Linq query syntax:
return from user in workspace.GetDataSource<User>() where UserSpecifications.IsSystemUser select user;
The compiler gives me cannot implicitly convert type 'Expression<Func<User, bool>>' to 'bool'
.
What gives? I thought Linq query syntax was just a cute DSL dressing up the extension method syntax. Can anyone tell me how I might use my lovely specifications with Linq query syntax?