Does anyone know how to deal with this error?
cannot convert from 'System.Guid?' to 'System.Guid'
Does anyone know how to deal with this error?
cannot convert from 'System.Guid?' to 'System.Guid'
See MSDN.
In that case, merely use myNullableVariable.Value (if you're sure it has a value), or (myNullableVariable.HasValue)?myNullableVariable.Value:somedefaulthere if you're not.
One can also use GetValueOrDefault() if one doesn't care if the default is a specific value when the nullable really is null.
The last way to do it is this: myNullableVariable.Value ?? defaultvalue.
See, technically a MyType? variable is a Nullable<MyType> under the covers. There are no implicit or explicit casts between the two, so what you need to do is extract the value out of the Nullable manually. The third way i listed is the most succinct (and best?) way to do it, to that would probably be best in most cases.
cannot convert from 'System.Guid?' to 'System.Guid'
you are trying to save type System.Guid? to a type system.Guid inside your model you can edit System.Guid? to System.Guid by removing the question mark.
or RCIX answer above
Simply use Nullable<T>.HasValue in if statement to check the value for null, then after it you can use Nullable<T>.Value to gets the value of an underlying type.
int? a = null;
if(a.HasValue){
Console.WriteLine($"a has value {a.Value}");
} else {
Console.WriteLine("No value found in a");
}