Page 1 of 1

SqlFunctions.DatePart with dotConnect

Posted: Thu 23 Jul 2015 20:38
by raffaelbechara
Can I use SqlFunctions.DatePart( ) with dotConnect for Oracle? (Linq to Entities)

If not, what is an alternative? OracleFunctions class?

If so, can you give an example please?

Thanks

Re: SqlFunctions.DatePart with dotConnect

Posted: Fri 24 Jul 2015 09:52
by Shalex
We will notify you when SqlFunctions.DatePart( ) is supported in dotConnect for Oracle.

As a workaround, please use the properties of the object:

Code: Select all

//var a1 = context.TSTABLEs.Where(b => SqlFunctions.DatePart("year", b.TSCOLUMN) == 2015).ToList();
var a2 = context.TSTABLEs.Where(b => b.TSCOLUMN.Value.Year == 2015).ToList();

Re: SqlFunctions.DatePart with dotConnect

Posted: Fri 24 Jul 2015 16:59
by raffaelbechara
Thank you for replying. Therefore, I'm still with a problem:

I can't use object property "Offset" because calling it throws an "unsupported" exception:

Code: Select all

b.Value.Offset
It works fine with properties like Day, Year, and some others. Therefore, I really need the "Offset" property.

Any suggests please?

Re: SqlFunctions.DatePart with dotConnect

Posted: Tue 28 Jul 2015 06:43
by Shalex
Try this way:

Code: Select all

var a3 = context.TSTABLEs.Where(b => System.Data.Entity.DbFunctions.GetTotalOffsetMinutes(b.TSCOLUMN) == 60).ToList();

Re: SqlFunctions.DatePart with dotConnect

Posted: Thu 07 Jul 2016 17:21
by Shalex
The SqlFunctions.DatePart method is supported in LINQ to Entities for the following modifiers: year, month, day, hour, minute, second, millisecond, tzoffset. The feature is available in the newest (9.1.55) build of dotConnect for Oracle.