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
How to achieve TRUNC functionality in devart?
-
- Posts: 13
- Joined: Fri 23 Apr 2010 21:16
Here is a LINQ to Entities example (for Entity Framework v4):
The OracleFunctions class is located in the Devart.Data.Oracle.Entity assembly.
Code: Select all
var q = from e in db.Emps
where OracleFunctions.Trunc(e.Hiredate, "Q") == OracleFunctions.Trunc(DateTime.Now, "Q")
select e;
I'd love to be able to do this, but unfortunately we're currently stuck on Visual Studio 2008 for a little while.AndreyR wrote:Here is a LINQ to Entities example (for Entity Framework v4):The OracleFunctions class is located in the Devart.Data.Oracle.Entity assembly.Code: Select all
var q = from e in db.Emps where OracleFunctions.Trunc(e.Hiredate, "Q") == OracleFunctions.Trunc(DateTime.Now, "Q") select e;
Are there any other options for working with dates available besides writing a SQL statement inline?
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;