Page 1 of 1

EF5: EntityFunctions.AddMonths() not working for negative values?

Posted: Wed 10 Dec 2014 14:26
by acsdeveloper
I am using dotConnect for PostgreSQL 7.3.293.0, EF 5 and PostgreSQL 9.3.

For the given database

Code: Select all

CREATE TABLE "Users"
(
  "Id" serial NOT NULL,
  "DateRegistered" timestamp without time zone,
  "Month" integer,
  CONSTRAINT "Users_pkey" PRIMARY KEY ("Id")
);

executing this query

Code: Select all

using (var db = new TestDatabaseContainer())
{
    var users = db.Users
        .Where(x => x.DateRegistered != null &&
                    x.Month != null &&
                    x.DateRegistered.Value >
                    EntityFunctions.AddMonths(DateTime.Today, -x.Month.Value))
        .ToList();
}
returns this error

Code: Select all

{Error: 22007: invalid input syntax for type interval: " -("Extent1"."Month") MONTH"}
Sample project here: http://puu.sh/doTOz/46f87e72d8.zip

Re: EF5: EntityFunctions.AddMonths() not working for negative values?

Posted: Thu 11 Dec 2014 10:17
by Shalex
Thank you for your report. We have reproduced the issue and are investigating it. We will notify you about the result.

Re: EF5: EntityFunctions.AddMonths() not working for negative values?

Posted: Wed 17 Dec 2014 14:24
by Shalex
The bug with SQL generation for AddYears, AddMonths, AddDays, AddHours, AddMinutes, AddSeconds, AddMilliseconds, AddMicroseconds, AddNanoseconds canonical functions is fixed. We will notify you when the corresponding build of dotConnect for PostgreSQL is available for download.

Re: EF5: EntityFunctions.AddMonths() not working for negative values?

Posted: Thu 18 Dec 2014 14:51
by Shalex
New build of dotConnect for PostgreSQL 7.3.313 is available for download!
It can be downloaded from http://www.devart.com/dotconnect/postgr ... nload.html (trial version) or from Registered Users' Area (for users with active subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?f=3&t=30982.