How can I check if a value exists in a list using C#
- by Samantha J
I have the following code that gives me a list of id and names from the new ASP.NET MVC5 Identity:
        var identityStore = new IdentityStore();
        var users =
          (
              from user in identityStore.DbContext.Set<User>()
              select new
              {
                  id = user.Id,
                  name = user.UserName
              }
          );
How could I modify this so that it allows me to check if a UserName exists?
Here's the user class:
public class User : IUser
{
    public User();
    public User(string userName);
    [Key]
    public string Id { get; set; }
    public virtual ICollection<UserLogin> Logins { get; set; }
    public virtual UserManagement Management { get; set; }
    public virtual ICollection<UserRole> Roles { get; set; }
    public string UserName { get; set; }
}