views:

155

answers:

2
private void EnsureCurrentlyValid()
{
    //I'm valid if IDataErrorInfo.this[] returns null for every property
    var propsToValidate = new[] { "Name", "Email", "Phone", "WillAttend" };
    bool isValid = propsToValidate.All(x => this[x] == null);
    if (!isValid)
        throw new InvalidOperationException("Can't submit invalid GuestResponse");
}


'System.Array' does not contain a definition for 'All' and no extension method 'All' accepting a first argument of type 'System.Array' could be found (are you missing a using directive or an assembly reference?) C:\dev\aspnet\PartyInvites\Models\GuestResponse.cs


What am I missing?

+5  A: 

Add this to the top of your file:

using System.Linq;
Lasse V. Karlsen
+1  A: 

All is an extension method defined on Enumerable. The extension methods (including All) are defined in the System.Linq namespace, so you need to include a using directive for System.Linq to your class in order to reference the extension methods. You'll also need to be using C# 3.0 and .NET 3.5.

tvanfosson