odatatools
odatatools copied to clipboard
How to convert query?
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!
Did you check out the wiki? https://github.com/apazureck/odatatools/wiki/Usage-of-Proxy-Client
Yes.. it dose not help me much .. I don't understand if I can do nested operations with the lib.
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.
Yes, no doubt it is correct. Thanks anyway.
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.