Page 1 of 1

How to achieve TRUNC functionality in devart?

Posted: Thu 30 Sep 2010 23:15
by thakkarmayank
Hi,
I am using Devart 5.60 and i want to query something like this:

Select * from myTable where Trunc(myDate) = Trunc(sysdate)

This works perfectly fine in oracle but Can somebody let me know how can i use this in my LINQ query?

If I use something like this:

var d = from t in myTable where myDate.Date == DateTime.Now() select t;

it throws me an error.
~Mayank

Posted: Fri 01 Oct 2010 12:29
by AndreyR
Here is a LINQ to Entities example (for Entity Framework v4):

Code: Select all

        var q = from e in db.Emps
                where OracleFunctions.Trunc(e.Hiredate, "Q") == OracleFunctions.Trunc(DateTime.Now, "Q")
                select e;
The OracleFunctions class is located in the Devart.Data.Oracle.Entity assembly.

Posted: Mon 20 Dec 2010 14:43
by glenn.apb
AndreyR wrote:Here is a LINQ to Entities example (for Entity Framework v4):

Code: Select all

        var q = from e in db.Emps
                where OracleFunctions.Trunc(e.Hiredate, "Q") == OracleFunctions.Trunc(DateTime.Now, "Q")
                select e;
The OracleFunctions class is located in the Devart.Data.Oracle.Entity assembly.
I'd love to be able to do this, but unfortunately we're currently stuck on Visual Studio 2008 for a little while.

Are there any other options for working with dates available besides writing a SQL statement inline?

Posted: Tue 21 Dec 2010 09:06
by AndreyR
Try the following code:

Code: Select all

var q = from e in db.EMP.Where("Devart.Data.Oracle.Trunc(it.HIREDATE, 'Q') == Devart.Data.Oracle.Trunc(@new, 'Q')", new ObjectParameter("new", par))
                select e;