User1 User1 - 8 months ago 83
C# Question

LINQ: Where on select result?

Is it somehow possible to use variant abc without having to call Convert twice ? I mean like def, but without a second from ?

Something like:

var desired = (from x in AnswerRecords
select Converter(x) as bla
where bla != null


Your case fits exactly the use of the let keyword. Check SO Documentation: Defining a variable inside a Linq query (let keyword)

Use it to store the result of the Converter and then check it:

var result = from item in AnswerRecords
             let converted = Converter(item)
             where converted != null
             select converted;