I have the following LINQ query:
var source = from em in query
select new
{
Id = em.UniqueID,
Data = em.Data == DateTime.MinValue ? "" : em.Data.Value.ToString("dd/MM/yy HH:mm")
};
The Data
property is of type Nullable<DateTimeOffset>
and so the Resharper shows me a warning saying:
Possible System.InvalidOperationException
And give me the 'hint' of changing this query to
var source = from em in query
let dateTimeOffset = em.Data
where dateTimeOffset != null
select new
{
Id = em.UniqueID,
Data = dateTimeOffset == DateTime.MinValue ? "" : dateTimeOffset.Value.ToString("dd/MM/yy HH:mm")
};
It seems that let
creates a variable in the middle of the query, is it?