Use FirstOrDefault instead of First. This will return null in the face of an empty collection.
IRepository<User> = new UserRepository();
User user = userRepository.FirstOrDefault(u => u.Name == userName);
JaredPar
2009-06-03 00:24:27