Skip to content
This repository has been archived by the owner on Nov 10, 2020. It is now read-only.

Filter using more than one condition #29

Open
dkotov opened this issue Apr 8, 2013 · 2 comments
Open

Filter using more than one condition #29

dkotov opened this issue Apr 8, 2013 · 2 comments

Comments

@dkotov
Copy link

dkotov commented Apr 8, 2013

So I'm trying to do next:

repository.Contacts
    .Where(c => c.ContactNumber == "Foo" || c.Name == "Bar")
    .ToList();

and when I check results I see that only one of these conditions was applied (right or left depending on what logical operator was used -- AND or OR).
At the same time when I try to do this filtering using API Preview it works fine: ContactNumber = "Foo" OR Name = "Bar"

Am I doing anything wrong?

@danbarratt
Copy link
Contributor

The c.ContactNumber == "Foo" is being parsed out of the WHERE filter and added as an id to the url path. The whole url would look something like this:

https://api.xero.com/api.xro/2.0/Contacts/Foo?WHERE=Name%3D%3DBar

The contact number property on each contact is considered a unique identifier. It makes the lookup in our database very fast when added to the url path, as opposed to the generic ?WHERE= filter, which is typically slower.

There's currently no way to force the XeroAPI.Net library to generate a ContactNumber = "Foo" OR Name = "Bar" WHERE querystring parameter.

Dan..

@dkotov
Copy link
Author

dkotov commented Apr 9, 2013

@danbarratt, thank you for your quick answer.
I see that API Preview allows retrieving Contact by ContactNumber in the same way as by ID too and I understand all the advantages of this approach. But API Preview doesn't deny filtering by these fields, so why XeroAPI.Net library behave differently?
Let me explain an issue that I have because of this optimization: I'm trying to retrieve batch of contacts by ContactNumber and currently I have to get each of them individually (which looks inefficiently and may lead to API limits exceeding) or get all of them each time (even with some filtering it's better but not good enough) or store them locally (which add complexity to my system).
So having an ability to choose between speed and functionality would be great for me and maybe for other developers.

UPD: I found workaround for my particular case.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants