How to achieve TRUNC functionality in devart?

How to achieve TRUNC functionality in devart?

Postby thakkarmayank » Thu 30 Sep 2010 23:15

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
thakkarmayank
 
Posts: 13
Joined: Fri 23 Apr 2010 21:16

Postby AndreyR » Fri 01 Oct 2010 12:29

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.
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Postby glenn.apb » Mon 20 Dec 2010 14:43

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?
glenn.apb
 
Posts: 1
Joined: Mon 20 Dec 2010 14:36
Location: GB

Postby AndreyR » Tue 21 Dec 2010 09:06

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;
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16


Return to dotConnect for Oracle