XeroAPI/XeroAPI.Net

Where clause containing UpdatedDateUTC problem

Closed this issue · 1 comments

If you try to use this:
repository.Invoices.Where(i => i.UpdatedDateUTC > DateTime.UtcNow.AddYears(-2) && i.Type == "ACCPAY");

it gets turned into:
{Name:Invoice Where:( AND (Type == "ACCPAY")) After: 2010-02-11T23:50:32}

Notice the UpdatedDateUTC has correctly been split out (I assume to be used in the HTTP header: ‘If-Modified-Since‘) but there is an "AND" sitting there at the start of the Where clause.

This returns the error: "The XeroAPI returned an ApiException response: no applicable method 'AND' exists in type 'Invoice'"

As a workaround you can change it to use two Where's:
repository.Invoices.Where(i => i.UpdatedDateUTC > DateTime.UtcNow.AddYears(-2)).Where(i => i.Type == "ACCPAY");

Hi Matt,

Yep, I think you found a gnarly bug with the way the If-Modified-Since headers are extracted from a WHERE clause. I think you are working on an old version of for XeroApi.Net library, as there was a fix for this added about 3 months ago (#6). If you get the latest source from github, this should work for you. Otherwise, I'll do another push to NuGet in the next hour or so to make sure the fix in in there.

Dan..