We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

DataManager Query Equivalent of SELECT * FROM table WHERE id IN (...)

I need to query an OData source to return records whose ID is in a list.  I assume this is possible with a Query, but I can't find the correct syntax.  Any help would be appreciated.


Thanks!

-k

5 Replies

PS Pavithra Subramaniyam Syncfusion Team October 3, 2019 08:37 AM UTC

Hi Kelly, 
 
Thanks for contacting Syncfusion support. 
 
You can achieve your requirement by using the “where” method of EJ2 DataManager Query. Please refer to the below documentation for more information. 
 
 
Regards, 
Pavithra S. 



KH Kelly Harrison October 3, 2019 06:34 PM UTC

Could you please post an example?  If I have an array

[2, 3, 4. 8, 9, 10, ...]

and a table as such:

ProductId,
CustomerId,
ProductName,
...


and I want all results where the customer_id is in that array...?

-k


PS Pavithra Subramaniyam Syncfusion Team October 4, 2019 12:15 PM UTC

Hi Kelly, 

Thanks for your update. 

By default one to many filtering is not supported in EJ2 DataManager. So we could not query the array values using DataManager which is the default behavior. 
 
Regards, 
Pavithra S. 



KH Kelly Harrison replied to Pavithra Subramaniyam October 4, 2019 05:39 PM UTC

Hi Kelly, 

Thanks for your update. 

By default one to many filtering is not supported in EJ2 DataManager. So we could not query the array values using DataManager which is the default behavior. 
 
Regards, 
Pavithra S. 


Is there a way to manipulate the OData query uri directly then?  It does appear that OData supports the 'IN' option:

http://host/service/Products?$filter=Name in ('Milk', 'Cheese')


PS Pavithra Subramaniyam Syncfusion Team October 7, 2019 09:34 AM UTC

Hi Kelly, 

Thanks for your update. 

Yes. You can achieve your requirement by using predicate which helps to build complex filter Query. Please refer the following documentation link for more information. 


Sometimes the built-in adaptors does not meet your requirement. In such cases you can create your own adaptor. Please refer the below documentation link for more information. You can override the default Query of the Odata Adaptor by overriding processQuery and processResponse methods. 

 
Regards, 
Pavithra S. 


Loader.
Live Chat Icon For mobile
Up arrow icon