简体   繁体   中英

how to consume Odata Service from Android using any library that contain select where statement

Is there a way to consume Odata Service from Android using Odata4j or any other library that contain SELECT WHERE Clause statement

I searched a lot but can't find any solution

For odata4j you need to instantiate a ODataConsumer Object - let's call it consumer. With this object you are able to perform any desired database actions. For example:

OEntity result = consumer.getEntities("YourEntityName").filter("Field2 eq 'xyz'").select("Field1, Field2, Field3").execute();

This would resemble the following SQL query

SELECT Field1, Field2, Field3 FROM YourEntityName WHERE Field2 = 'xyz'

For more information regarding the string arguments for filter() and select() you should have a look into the odata documentation at odata.org -> URI conventions.

If you want to understand the java functions of odata4j use the documentation at odata4j documentation .

I can also recommend the odata4j example files .

Nice question......

We can access the odata service by using AsyncHttpClient in android.

Here we need to override some methods ,and its taking RequestParams as a parameter will return data as json or xml.

you can read more on AsyncHttpClient Here : http://loopj.com/android-async-http/

here we can pass RequestParams,it will take select as key and query as your original query. try it and let me know if you have any issues

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM