New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is possible for your tool to cover a such scenario ? #15
Comments
Hello. My project allows creating global filters on entities using simple boolean expressions. What you are describing would not apply to my project but can be accomplished with Entity Framework out of the box. I think something like this (in C#, my language of preference) is what you are trying to do?
Basically, you can just keep appending more .Where() clauses to your IQueryable. EF will not execute it until you do the ToList() at the end and the resulting sql query will contain all the conditions you have added to your query. Hope that helps. |
Hello ! The problem is on condition3 . The way you construct this query would mean : " Select all the Articles that have on "childCollection" at least one child with c.type=3. If you can read carefully my first post , this is not what I want. I want : " For all articles in Mylist , Include only those childs from childsCollection that have c.type=3. This is not supported from Entity Framework out of the box , because if I will translate my request , will be an Include() with filter that EF doesn't support out of the box. For what I ask you if your product can do anything. So , is there any solution ? Thank you ! |
Sorry, I misunderstood your question and didn't realize you were asking about filtering the child collection. You can do that with this project. There are examples of doing this in the example project in the source. Look for how a filter is created on BlogEntries. That is a child collection on Accounts. Filters apply to all queries against an entity no matter how they are done - directly against the DbSet or via Include(). If you need to conditionally change the filter, you can do that by either disabling it or changing the parameter values. There are examples of both in the example project and on the main page. Sorry, I can't give more specifics atm. I'm literally walking out the door for vacation. |
Hello ! |
Please give me some help ! |
Here is an example how you can accomplish this. I've tried to match it as closely to your VB/pseudo code as possible. I'm not a VB guy so you'll have to convert this from C#. Models:
Filters:
Run your query with condition checks and get results:
I have defined 3 global filters on the F!Child and F2Child entities. These will be enabled by default so you would need to disable them if they should not be used. I am also setting the values using SetFilterScopedParameterValue because I'm assuming those values may vary. 2 of the filters are on F1Child and can be used together or independently. As I said, the filters are enabled by default. There is currently no way to disable them by default, but you could define the filters something like this:
Here, the default value I am setting for "quantity" is -1 so it will effectively return all records (and thus disable the filter) unless "quantity" is set via a call to SetFilterScopedParameterValue() or SetFilterGlobalParameterValue(). Remember that these filters will apply globally to all queries that involve F1Child and F2Child entities. It may be worthwhile for me to add an option to the filter creation that allows the filters to be disabled by default so that you can selectively opt-in to filters that should not be used globally. But until then, you can accomplish that as I have shown above. |
Hello !
I want to know how is possible to do with your tool , the below scenario :
Article - has 2 child entities F1 and F2.
I want to construct the query step by step depending from some condition , and at the end I want to get data from database using Tolist.
Dim mylist as iQuerable(Of Article)
Mylist=Context.Set(Of Article)
If condition1 then ...."From Mylist filter the articles with ".vl1=1 ..." End if
If Condition2 then ..."From Mylist filter the articles with ".id>=5 ..." End if
If Condition3 then ....For all the articles in MyList , include the items on child F1 that have ".quantity>3".... End if
If condition4 then ....For all the articles in MyList , from the items on child F1 that are included from the previous condition3 , include only those that have ".value5=0.... end if
If condition5 then ....For all the Articles in MyList , include the items from child F2 that have .type=3....." End if
MyList.Tolist
How is possible to create this ? A solution would be very helpful.
Thank you !
The text was updated successfully, but these errors were encountered: