XeroAPI/XeroAPI.Net — Issue #14: Where clause containing UpdatedDateUTC problem
Author: mattkemp
Created: 2012-02-12 00:37:11+00:00
State: open

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");