If the resulting values ββare an object of a reference type, then, indeed, FirstOrDefault can return null, and therefore you cannot call TotalCashIn.
If, on the other hand, the totals are a value type, then FirstOrDefault will return the actual value, and you can call TotalCashIn. For example, if the totals are a sequence of integers, then FirstOrDefault will return zero (not null!).
If TotalCashIn is an int extension function, then if it would be ideal to call TotalCashIn after FirstOrDefault:
IEnumerable<int> totals = ... int firstInt = totals.FirstOrDefault(); var totalCashIn = firstInt.TotalCashIn();
or in one statement:
var totalCashIn = totals.FirstOrDefault().TotalCashIn();
Whether it is possible to use an operator with a null condition (?.) Depends on the definition of your TotalCashIn, especially if your collection does not have an element at all.
If you say: "TotalCashIn represents the amount of money that I cashed while ...", then TotalCashIn can have a zero value, but not a zero value.
If you want to get a null value in the case of empty collections, consider using Select to select the property you want before your FirstOrDefault:
var totalCashIn = totals.Select(item => item.TotalCashIn).FirstOrDefault();
If the TotalCashIn property is a value type, then this will return zero if the totals collection is empty
As for your question, should I use Count () or Any (): never use Count () to check if your sequence has any elements if you are not sure if your input sequence is an ICollection. In fact, it is a waste of computing power to access all the elements of your sequence, if after the first element you already know that there are elements.