So I need to do a query where I need a bunch of NVL's but I need to do these in linq (if it helps the db backend is BD2 and we are using subsonic) I searched the web for "NVL linq" and didn't really find anything useful so I am asking here,
Thanks for your help...
The advantage of the COALESCE() function over the NVL() function is that the COALESCE function can take multiple alternate values. In simple words COALESCE() function returns the first non-null expression in the list.
It will return an empty enumerable. It won't be null.
NVL. The NVL function allows you to replace null values with a default value. If the value in the first parameter is null, the function returns the value in the second parameter. If the first parameter is any value other than null, it is returned unchanged.
What is the difference between nvl and nvl2? Answer: The nvl function only has two parameters while the nvl parameter has three arguments. The nvl2 like like combining an nvl with a decode because you can transform a value: NVL ( expr1 , expr2 ): If expr1 is null, then NVL returns expr2.
You can use the null coalescing operator ??
:
var abs = from row in table
select new {a = row.a ?? "default", b = row.b};
The operator looks at the value on the left and if it is null then it uses the value on the right. So in the example if row.a
is null, then a
becomes "default"
.
This assumes that row.a
is a string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With