2

I am new to my project, in the project they used Entity Framework & LINQ to manipulate the DB data. Here I am not able to understand why the question mark (?) is used after get() method in the following query. Is it possible to use the (?) mark as like below ?. If yes, then could you please explain in detail.

 uOW.ApplicationDetailsRepository.Get()?
                    .Where (x=>x.Name=="SomeConditions").Tolist();
Md Aslam
  • 1,228
  • 8
  • 27
  • 61
  • 4
    To be fair to the poor fellow, the way the code is written with the LINQ `.Where` appearing on the following line makes it hard to realise that the `?` is being used in conjunction with the `.`. Makes it harder to Google –  May 04 '18 at 05:36
  • Thanks @Stephen Muecke for editing the question. I did't find the link while searching this question in stack-overflow, so only asked my question. – Md Aslam May 04 '18 at 06:51

1 Answers1

6

When the question mark is used this way (in combination with the period: ?.), it is called the Null-conditional operator. It is a check for null before attempting the rest of the statement.

Here is a reference explaining in detail.

egnomerator
  • 985
  • 8
  • 15