I’ve tried several methods to compare years in a date, but each time I’m getting the “Invalid ‘where’ condition. An entity member is invoking an invalid property or method.”-error!
The methods I’ve used :
var openInvoices = orgContext.CreateQuery<Invoice>().Where(i => i.SKY_InvoiceDate.Value.Year == 2010);
var openInvoices = orgContext.CreateQuery<Invoice>().Where(i => i.GetAttributeValue<DateTime?>("SKY_InvoiceDate".ToLower()).Value.Year == 2011);
var openInvoices = orgContext.CreateQuery<Invoice>().Where(i => i.SKY_InvoiceDate.Value.Year.Equals(2010));
IS there a way where I can get all the invoices for the year 2011?
Thx for all the help!
The problem is that the call to the Year property of DateTime can’t be translated properly. A simple workaround: