-1

Good Day.

Sorry before i'm a beginner on linq. can i ask what is the meaning of ?? in linq

.Where(w => ((w.BalancedDate ?? w.OriginalDateByAMT) >= filter.start_date && (w.BalancedDate ?? w.OriginalDateByAMT) <= filter.end_date) || w.ReplaceByEHValidation == true)

Thanks

Jackie
  • 118
  • 13

3 Answers3

2

It's not a linq operator, but it means if the left hand property is null, then use the right hand property.

Keith Rousseau
  • 4,435
  • 1
  • 22
  • 28
  • So its like COALESCE or ISNULL on SQL? – Jackie Dec 18 '18 at 03:25
  • @Randy, Exactly, in fact it's call the null coalescing operator https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-coalescing-operator – juharr Dec 18 '18 at 03:56
1

If the value on the left side of ?? is null, then it takes the value of the right side.

I.e.

var x = y ?? z;

If y is not null then x=y otherwise x=z

Ro.
  • 1,525
  • 1
  • 14
  • 17
0

Yes, this question was already answered on the link shared on the comments. It is a Nullable type or null-coalescing, it returns the left value if not null or else it returns the right one.

John Mor
  • 9
  • 1