为什么我在查询中使用Plinq,例如
var notNullParameterValues = (from operation in operations.AsParallel()
where operation.NullableParameter.HasValue
select operation.NullableParameter.Value)
.Distinct().ToList();
resharper警告我可能的System.InvalidOperationException'?
为简单起见,操作是IList<Operation>;
public class Operation
{
public int? NullableParameter {get; set;}
}
更新:谢谢大家的回答。
答案 0 :(得分:1)
答案 1 :(得分:0)
var notNullParameterValues = (from operation in operations.AsParallel()
let nullableParameter = operation.NullableParameter
where nullableParameter != null
select nullableParameter.Value).Distinct().ToList();