Pass a parameter to global query filter - entity-framework-core

With new ef.core global query filters, is it possible to pass a dynamic parameter to it?
I want all queries to be filtered by user's company id. All models have a companyId value. I know there are libraries like this one, but is there a native way to achieve it?

Related

Provide general query statement for all particular events

the following real use case, that already has been implemented by our company:
We've built application with rest api as wrapper around esper java api.
The user can define it's map schema and query statement.
Each event (instanceof MapEventBean) sent by user (as JSON) has one common parameter (thou with different values every time), which are to be added to map in background to the user map event as additional key-value pair.
Problem: in order to retrieve this additional parameter by UpdateListener, the user defined both schema and query statement are to be extended programmatically over this attribute.
E.g.:
User defined schema: create map schema Name as (...)
Prog. modified schema: create map schema Name as (additionalAttribute Map, ...)
User defined query stmt: select foo, bar from Name
Prog. modified query stmt: select additionalAttribute, foo, bar from Name
Question: approach does work, but is very error-prone or not too independent, as we'd like to have it.
So the question: Is any possibility to define common query stmt (e.g. select additionalAttribute on each event ...) or tell update listener to retrieve the particular attribute on each succeeded query, independently of whether it has been defined in user defined stmt or not.
Thanks in advance!
Update:
I've already considered some possibilities such as NamedWindows, but the problem is, that this additional attributes are to belong to each particular event, - that is the attributes should be fetched from pattern by update listener simultaneously with the event self.
There is a statement object model API that you can use to modify the queries without doing string manipulation. The documentation link for the API is http://esper.espertech.com/release-8.0.0/reference-esper/html_single/index.html#apicompiler-soda

How to fetch distinct list from SpringData without using query annotation?

I am using 2 different properties to fetch distinct list eg
findDistinctBy<propertyName>And<propertyName>In(List<String> list).
My actual Spring jpa statement is
List<PojoClass> findAllByTpIdInAndDistinctMobile(List<String> edgeIds);
where TpId & Mobile are 2 different properties in PojoClass. I need to implement this without using Query annotation. Any suggestions of queryDsl will also do.
The question needs to be more clear.What exactly do you intend to achieve when the input is a list of Ids?
There is no option to provide a list to findAll unless it is an Id.
A simple way would be to loop the the input list in service and append the result to a result list.
for(String edgeId:edgeIds){
resultList.addAll(findByEdgeId(edgeId));
}
Updated code after #Tejas comment
for(Pojo pojo:Pojos){
resultList.addAll(findDistinctPojoByPropert1OrPropert2(String pojo.getProperty1(),String pojo.getProperty2());
}

Where are stored filter params in magento 2?

I need to export the products catalog after I applied a filter. I made a custom button for this, but in the query I need the filters already applied on the grid. Is it possible to get them from the global variable? I noticed that if I refresh the page, the filters are kept, but I do not know where they are from.
You can find applied filters data at the ui_bookmark table of your database;
SELECT `namespace`, `config` FROM `ui_bookmark`;

Rest API: How should the filter params send to API in case query based on nested resource

I have two entities Properties and Bookings.
I need to know the URL structure in case I'm filtering the properties base on query on bookings.
In my case I need to get the properties which are free (not occupied) at specific date.
Can it be
api/properties/free/{date}
Or
api/properties/bookings?bookingDate!='1-1-2017'
Or
api/properties?bookingDate!='1-1-2017'
it seems for me that the last one is the more appropriate but the filter is on the bookings not on the properties which is not obvious.
The Facebook Graph API has a interesting way of doing nested queries by using a strategy of fields filter.
The fields filter it´s a way of filter specific fields or nested fields of a rouserce. They also create a standard way to inform functions for every selected field like: limit or equal.
Your request would be something like this:
GET /api/properties?fields=bookings{bookingDate.notEqual('1-1-2017')}
For more information about Facebook´s GraphAPI:
https://developers.facebook.com/docs/graph-api/overview/

How to make a GET request using a filter on a datetime property with EspoCRM REST API?

EspoCRM provides a REST API that sadly has only incomplete documentation. Especially the filters that can be used with a GET request are not documented:
where - (array) filters;
From using Firebug I've discovered that a filter consists of three query parameters:
where[0][field]=somefield
where[0][type]=somoperator
where[0][value]=somevalue
Example, filter on name=Foo:
?where[0][field]=name&where[0][type]=equals&where[0][value]=Foo
The meaning of equals is not documented, as are the possible filter types.
Now I want to filter a collection on a datetime field modifiedAt. I have no idea what the proper values for type and value would be to find all entities that have been modified after a given datetime.
How can the EspoCRM REST API be used for this?
After playing around with the EspoCRM web GUI, I was able to make a search that uses the filter I need. The query parameters are:
where[0][type]=after
where[0][field]=modifiedAt
where[0][value]=2016-06-01 16:12:00
where[0][dateTime]=true
where[0][timeZone]=Europe%2FBerlin