I'm using System.Linq.Dynamic.Core version 1.0.7.6 with EF and Oracle.ManagedDataAccess.EntityFramework 12.1.2400.
Any idea why dynamic query like
EntitySet.Where($"Date == @0", date)
is translated to sql :
SELECT * FROM "Schema"."Entities" "Extent1"
WHERE (TO_TIMESTAMP('2016-02-12 00:00:00.000', 'YYYY-MM-DD HH24:MI:SS.FF') = "Extent1"."Date")
Notice the TO_TIMESTAMP
function call.
While standard Linq query on the same context and the same set
EntitySet.Where(p => p.Date == date)
is translated to :
SELECT * FROM "Schema"."Entities" "Extent1"
WHERE ("Extent1"."Date" = :p__linq__0)
No TO_TIMESTAMP
function call
The difference is that the way you are using it, Dynamic LINQ binds the passed variables by value, which is equivalent of using constant values inside the static query. The equivalent static LINQ would be
EntitySet.Where(p => p.Date == new DateTime(2016, 02, 12))
which will translate the same way as the sample dynamic query.
If you wish to let Dynamic LINQ bind the variables as parameters to the resulting query, you can use anonymous type with properties like this:
EntitySet.Where($"Date == @0.date", new { date })
which will be translated the same way as your sample static query.