本文介绍了返回键用的ModelState错误列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想回有针对他们的错误的所有键的列表/数组。我试图做ModelState.ToList(项目=> item.Value.Errors.Count> 0),但它说我不能有那种前pression出于某种原因。

感谢


解决方案

  VAR错误的ModelState中=在ModelState.AsQueryable()式(F =方式> f.Value.Errors。计数大于0)选择新的{标题= modelstate.Key};

I would like to return a list/array of all keys that have an error against them. I have tried to do ModelState.ToList(item => item.Value.Errors.Count>0) but it says I can't have that sort of expression for some reason.

Thanks

解决方案
var errors = from modelstate in ModelState.AsQueryable().Where(f => f.Value.Errors.Count > 0) select new  {  Title = modelstate.Key  };

这篇关于返回键用的ModelState错误列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 08:07