Checking for presence

Sep 26, 2009 at 7:35 PM

In your file WWPlatform.DataAccess/Repositories/CustomerRepository.cs you have this code:

public bool CustomerExists(string email)
{
  return Entities
    .Count(c => c.Email == email) > 0;
}

I would propose changing this to:

public bool CustomerExists(string email)
{
  return Entities
.Any(c => c.Email == email); }

The former approach requires Linq to traverse the entire enumeration, the latter (theoretically) does not.