Use NVL in LINQ

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
Citt_jr
Posts: 6
Joined: Wed 28 Sep 2011 08:44

Use NVL in LINQ

Post by Citt_jr » Wed 28 Sep 2011 09:14

Hello,

How to use the Oracle function NVL in LINQ ?

Exemple :
SELECT *
FROM TABLE
WHERE Field = NVL(1020, UID)

LINQ
query.Where(t => t.Field == ??????);

Thanks

Citt_jr

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Thu 29 Sep 2011 16:23

No .NET methods are translated into the NVL Oracle function. However, you can get the same result by using the null-coalescing operator ('??' in C#):

Code: Select all

query.Where(t => t.Field == UID ?? 1020);
Please tell us if this helps.

Citt_jr
Posts: 6
Joined: Wed 28 Sep 2011 08:44

Post by Citt_jr » Mon 03 Oct 2011 07:02

Hello,

I need this feature to improve the query plan because you do not manage HINTS

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Tue 04 Oct 2011 13:41

We will consider implementing the translation of the null-coalescing operator to the NVL function. However, we cannot provide any timeframe for this feature.

At the moment, you can use this function or hints manually via the ExecuteQuery generic method:

Code: Select all

var query = dataContext.ExecuteQuery(
  "select field1, field2, ... from myTable where field1 = NVL(...)"
);
or add text WHERE conditions via the Dynamic Query library:

Code: Select all

query = query.Where("field1 = NVL(...)");

Post Reply