-
Notifications
You must be signed in to change notification settings - Fork 38
Support filters like "document.Permisions.Any(p => p.UserId == userId)" #11
Comments
I started to debug your code. thrown at:
of your ParameterReplacer, even though I gave it a constant filterexpression:
the expression tree is as follows:
I am unfortunately new to this subject. Could you please give me any insights? |
Ok... so now building the expression tree seems to work finally.
so now it blows up in the second last line of FilterQueryVisitor.Visit(...)
with the error: A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in EntityFramework.dll Additional information: No property with the name 'AccessPredicates' is declared by the type 'CodeFirstDatabaseSchema.Document'. AccessPredicates is a navigationproperty on Document, however the EdmType (I debugged entity framework where the error is thrown: System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder.Internal.ArgumentValidation.ValidateProperty) However, if I do not use the filter, and write the query manually like so:
then the "Member" collection contains "Id", "Title", "AccessPredicates" and "Chapter" as I'd expect. It seems to me that EntityFramework constructs the StructuralTypes (which inherit EdmType) |
For ease of debugging, I added a test project: http://1drv.ms/1BbrBAL |
Sigh. So yeah, it turns out manipulating queries is actually really quite difficult. I don't know much more than you do to be honest, it was a lot of going through the EF source code when I made this, but I still don't understand everything going on, it's mostly undocumented. |
Hi! Posted this to EF team. Here is the answer: dotnet/efcore#515 (comment) Do you understand anything from this? Besides: Seems your EF.Filters applies the parameters of a parameterized filter BEFORE the query is cached. So the query is cached with the first parameter applied. Once I change the parameter (e.g. in another DbContext instance) the query in cache has still the old parameter and not its placeholder, so the new one is not applied. I have to explicitly disable query caching to avoid this. Any hints about that? |
Can you try the latest version now? There was a pull request to change to the CSpace, which I think helps here (no more caching) |
Oh thanks - seems I overlooked that. And do you know what is meant by the "IStoreModel" by dotnet/efcore#515 (comment) ? Cite: "Investigation: |
Well, no, but I can dig more into it. |
No it's ok. Just thought you could understand this rather short hint of the EF team member. :) |
Hi!
I know you write in your documentation, that your solution does not support "Complex Join Logic"
However, I always have the very same join semantic like so:
So every resource points to an AccessPredicate table which is just a table consisting of "ResourceId, UserId".
Would this scenario be hard to implement?
What steps would I have to follow?
The text was updated successfully, but these errors were encountered: