5
如何返回有错误的所有密钥的列表/数组?返回带有ModelState错误的密钥列表
我试图做到以下,但它说我出于某种原因不能有这种表达。
ModelState.ToList(item => item.Value.Errors.Count > 0)
如何返回有错误的所有密钥的列表/数组?返回带有ModelState错误的密钥列表
我试图做到以下,但它说我出于某种原因不能有这种表达。
ModelState.ToList(item => item.Value.Errors.Count > 0)
var errors = from modelstate in ModelState.AsQueryable().Where(f => f.Value.Errors.Count > 0) select new { Title = modelstate.Key };
计数是一种方法。你需要()。但我更喜欢的任何,反正:
from item in ModelState
where item.Value.Errors.Any()
select item.Key
无重载方法“ToList”采取“1”参数 – Jon 2009-05-20 16:01:11