Hi.
I´m using LinqConnect 4.4.727 against Postgres 9.4.
I devised a LINQ Dynamic user´s query facility. It works ok, but when the target property is a DateTime (mapped to timestamp) there is no way the query succeed. Suppose, as an example, the property is called startDate, and the user selects a LessThan operator, with a predicate of 2016-11-05.
The primary contruction ( "startDate < '2016-11-05' ) is rejected by the Dynamic.cs module, because cannot compare a DateTime against a string or (worse) char constant.
The recommended way to go is to use an implied constructor
"startDate < DateTime(2016, 11, 05)"
Using this form, LinqConnect throws an exception, telling some object is not mapped to the table. I suppose the not "mapped object" is the constructor DateTime(...)
My last attempt was to construct a complete expression of the form
"startDate.Year < 2016 || ( startDate.Year == 2016 && startDate.Month < 11 ) || ( startDate.Year == 2016 && startDate.Month == 11 && startDate.Day < 5 )". This time the exception is thrown at Devart.Data.Linq.Engine.j.b.a(SqlExpression A_0, Type A_1), "Object reference not set..."
Could someone help? I´m between two fires: on one side, Dynamic LINQ which cannot understand date constants; on the other, Linq Connect which cannot understand a constructor as a predicate or cannot understand some properties of the DateTime type at runtime.
TIA
Dynamic LINQ fails with DateTime / timestamp columns
Re: Dynamic LINQ fails with DateTime / timestamp columns
Sorry. It was my guilt.
I´m working with three solutions at a time: my base library (which builds the string expressions for the Dynamic LINQ, among other things), the "DAL" library (the one with the LinqConnect classes) and the application properly.
On some of the updates to the first one, surely I did not rebuild the others, so, even if I found the trick, it was not reflected. In short, to be useful for other users, to pass a DateTime predicate to Dynamic LINQ library, it must be of the form
" DateTime( year, month, day ) "; in my example, the complete expression result in
"startDate < DateTime( 2016, 8, 11 )".
It works like a charm.
I´m working with three solutions at a time: my base library (which builds the string expressions for the Dynamic LINQ, among other things), the "DAL" library (the one with the LinqConnect classes) and the application properly.
On some of the updates to the first one, surely I did not rebuild the others, so, even if I found the trick, it was not reflected. In short, to be useful for other users, to pass a DateTime predicate to Dynamic LINQ library, it must be of the form
" DateTime( year, month, day ) "; in my example, the complete expression result in
"startDate < DateTime( 2016, 8, 11 )".
It works like a charm.
Re: Dynamic LINQ fails with DateTime / timestamp columns
Thank you for letting us know.