Expression<Predicate<WithId>> idEqualToId2 = _ => _.Id == "id1";
You need to change "idEqualToId1" in your 2nd query to this:Expression<Predicate<WithId>> idEqualToId2 = _ => _.Id == "id1";
This should workstore.OpenSession().Query<WithId>().Where( idEqualToId1).ToList(),
Johan,What are you _trying to do_?
Changing the type of idEqualToId1 to "Expression<Func<WithId, bool>>" as the error hints seems to fix the problem though. As where clauses always returns a bool there should perhaps be an overload for this?
No, don't do things like that.
First, that interface is going to drastically reduce the usability that you can get from the client API.
Second, you are trying to pass a delegate, but Linq requires expressions.
Moreover, the linq API requires Func<...>, to work.
Ok. I guess that one could say that the different Linq implementations breaks LSP. Not much to do about that perhaps.
I suppose, except that have to do different things.Ok. I guess that one could say that the different Linq implementations breaks LSP. Not much to do about that perhaps.
LINQ-to-SQL, LINQ-to-EF or the RavenDB LINQ provider need an Expression<Func<..>> so that they can parse the expression tree and generate the relevant SQL or RavenDB server calls.Whereas LINQ-to-Objects is all in-memory so it only needs a Func<..> that it can execute when needed.Normally the compiler hides all this from you and does the work necessary depending on whether your source is IEnumerable<T> or IQueryable<T>. But in your case you're not doing it all in-line, instead you're storing the function in a variable, so you have to do the Expression<Func<..>> bit manually,