LINQ is not ideal for performing side effects for an existing collection. If this is what you want to do, you would be better off:
foreach(var node in MyNods)
{
if(!node.ParentId.HasValue)
node.ParentId = 0;
}
, . ; , , :
var source2 = from s in source
select new
{
s.Id, s.Name,
ParentId = s.ParentId ?? 0
};
EDIT:
, (.. , , , ), . , "" ( ) , , , - . :
var source2 = source.Select(s => s.ToNonNullableParentVersion());
EDIT:
, , "coalesced" nullable. , , .