SqlFunctions.DatePart with dotConnect

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
raffaelbechara
Posts: 3
Joined: Thu 09 Jul 2015 13:47

SqlFunctions.DatePart with dotConnect

Post by raffaelbechara » Thu 23 Jul 2015 20:38

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

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Re: SqlFunctions.DatePart with dotConnect

Post by Shalex » Fri 24 Jul 2015 09:52

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();

raffaelbechara
Posts: 3
Joined: Thu 09 Jul 2015 13:47

Re: SqlFunctions.DatePart with dotConnect

Post by raffaelbechara » Fri 24 Jul 2015 16:59

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?

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Re: SqlFunctions.DatePart with dotConnect

Post by Shalex » Tue 28 Jul 2015 06:43

Try this way:

Code: Select all

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

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Re: SqlFunctions.DatePart with dotConnect

Post by Shalex » Thu 07 Jul 2016 17:21

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.

Post Reply