odatatools icon indicating copy to clipboard operation
odatatools copied to clipboard

How to convert query?

Open LucaGabi opened this issue 6 years ago • 5 comments

Hi,

If I have this query:

fetch(`http://localhost:5000/odata/
                    Doctors?$select=Name&
                    $filter=DoctorSpecializations/any()&
                    $expand=DoctorSpecializations(
                        $select=SpecializationId,Specialization;
                        $expand=Specialization($select=Name))`)

How to write it with the proxy lib?

Thanks!

LucaGabi avatar Jun 03 '19 17:06 LucaGabi

Did you check out the wiki? https://github.com/apazureck/odatatools/wiki/Usage-of-Proxy-Client

apazureck avatar Jun 03 '19 20:06 apazureck

Yes.. it dose not help me much .. I don't understand if I can do nested operations with the lib.

LucaGabi avatar Jun 03 '19 21:06 LucaGabi

That's a good question. I think you could use the custom query option for this and just paste your code in there, so like:

const comm = new MovieProxy("http://localhost:5000/odata", "Testproxy");
const result = comm.Doctors.Custom("$select=Name&$filter=DoctorSpecializations/any()&$expand=DoctorSpecializations($select=SpecializationId,Specialization;$expand=Specialization($select=Name))").Get();

And the semicolon is disturbing. You are sure that's a proper odata query?

Best practice is to start simple, just do one query at a time. It also may depend if your odata server allows all queries, like expand and select or the any function.

apazureck avatar Jun 03 '19 21:06 apazureck

Yes, no doubt it is correct. Thanks anyway.

LucaGabi avatar Jun 03 '19 21:06 LucaGabi

I think the proxy does not support filter functions with the function syntax. So custom query should do the trick anyway. Let me know if it worked. You may also be able to extend the outcome by editing the template.

apazureck avatar Jun 03 '19 21:06 apazureck