当我尝试设置时IsDefault
每个敷料项目的属性如果符合条件,就会抛出错误:
序列包含多个匹配序列。
(this.DressingItems
.Where(xx => xx.DressingInfo.CatID == catId
&& xx.ProductID == this.ProductID)
.Single()).IsDefault = false;
嗯,这个异常表明序列中至少有两项DressingItems
匹配你的Where
健康)状况。致电给Single
then 会导致异常,因为它断言仅传入一项。
阅读你的问题让我觉得你想对输入序列的每个项目做一些事情,所以你可能会使用 foreach 循环:
foreach(var item in this.DressingItems.Where(xx => xx.DressingInfo.CatID == catId && xx.ProductID == this.ProductID))
{
item.IsDefault = false;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)