Check Collection.Count

May 3, 2010 at 2:23 PM

How to check, that a collection Count is > 0

Check(o => o.OrderDetails).Required("My error message");
Check(o => o.OrderDetails.Count > 0).Required("My error Message");

Seems not to work. Any Idea?

May 3, 2010 at 3:58 PM
Marinko, Check(o => o.OrderDetails).Required("My error message") should work for this situation. Required on a collection will verify that it's initialized and has at least one item in the collection. If you still find this not working, can you post send us a test case that is failing?
May 7, 2010 at 1:02 PM

You are right, no idea why it didn't work :-)

Thanks a lot :-)