Operator ‘?’ cannot be applied to operand of type ‘T’

Since not everything can be null, you have to narrow down T to be something nullable (aka an object). Structs can’t be null, and neither can enums. Adding a where on class does fix the issue: public abstract class Feature<T> where T : class So why doesn’t it just work? Invoke() yields T. If GetValue … Read more

Why can’t I use the null propagation operator in lambda expressions?

It’s complicated since expression tree lambdas (unlike delegate lambdas) are interpreted by already existing LINQ providers which don’t yet support null propagating. Converting to a conditional expression is not always accurate as there are multiple evaluations while with ?. there’s only a single evaluation for example: customer.Where(a => c.Increment()?.Name) // Written by the user customer.Where(a … Read more

An expression tree lambda may not contain a null propagating operator

The example you were quoting from uses LINQ to Objects, where the implicit lambda expressions in the query are converted into delegates… whereas you’re using EF or similar, with IQueryable<T> queryies, where the lambda expressions are converted into expression trees. Expression trees don’t support the null conditional operator (or tuples). Just do it the old … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)