I am getting this error in a LINQ
query with the below code:
"Operator '??' cannot be applied to operands of type 'System.Guid?' and 'string'"
I have a nullable GUID object
, here I am checking if the GUID Object
is null
, then I need to return
String.Empty
else will be converting GUID
to string
List<Report> queryresult =
reportDatatable.AsEnumerable()
.Where(c => c.Field<Guid?>("ParentID") == Guid.Parse("XXXXXX-XXX-XXXXX-XXXXX-XXX))
.Select(c=> new Report()
{
ID = (c.Field<Guid?>("ID") ?? String.Empty).ToString(), //error here
...
}).ToList();
Below link as simplest way to check whether object
is null
or not.
Suggest if any other approach to check GUID object
is null
or not