Can't use ternary operator to assign Linq expression

前端 未结 3 1501
轻奢々
轻奢々 2020-12-11 09:46

I just typed the following code:

Expression> expression = 
                fileTypeGroupID.HasValue ? n => n.Document.         


        
3条回答
  •  再見小時候
    2020-12-11 10:26

    fileTypeGroupID.HasValue ? (ContentItem n) => n.Document.MimeType.FileTypeGroupID == fileTypeGroupID.Value
                             : (ContentItem n) => true;
    

    Note the conditional operator is the correct name for ? : It's an example of a ternary operator (and is the only ternary operator in many programming languages).

提交回复
热议问题