BrokenRulesCollection order

BrokenRulesCollection order

Old forum URL: forums.lhotka.net/forums/t/9185.aspx


j055 posted on Thursday, July 08, 2010

 Hi

I noticed that when I loop through the BrokenRulesCollection the order appears to be somewhat random. e.g.

if (!model.IsValid)
{
    foreach (BrokenRule brokenRule in model.BrokenRulesCollection)
    {
        ModelState.AddModelError(brokenRule.Property, brokenRule.Description);
    }
    return View(model);
}

 Is the order something I can determine in the business class?

Thanks
Andrew 

RockfordLhotka replied on Thursday, July 08, 2010

No, the order is indeterminate. However, you can always use a LINQ query to sort the list as you see fit.

Copyright (c) Marimer LLC