Use NVL in LINQ

Use NVL in LINQ

Postby 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
Citt_jr
 
Posts: 6
Joined: Wed 28 Sep 2011 08:44

Postby 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.
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Postby Citt_jr » Mon 03 Oct 2011 07:02

Hello,

I need this feature to improve the query plan because you do not manage HINTS
Citt_jr
 
Posts: 6
Joined: Wed 28 Sep 2011 08:44

Postby 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(...)");
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48


Return to dotConnect for Oracle