Q:

Search a list of objects using object attributes

I am developing a software for managing members for a club.I created an offline search function that takes 3 parameters which are object attributes and returns a list of Members.
Member class has :
String name;
String email;
String telephone;

search method :
public static List<Member> Search(String name, String email, String telephone,String username)

The method uses at least one of the attributes to search. How can I make it work on 1 attribute , 2 , or 3 in case the user knows the name, email, and telephone of the Members. I was doing this :
if (name  != String.Empty) && email != String.Empty) && telephone != String.Empty))
{
   if (Member.FirstName.Equals(name) && Member.Email.Equals(email) && Member.Telephone.Equals(telephone))                            
       members_list.Add(Member.);
}
else if(name.Length > 0 && (email != String.Empty && telephone != String.Empty))
{
    ...
    ...
    ...etc
}

In sql it is quite easy 
 WHERE (FirstName = @FirstName or @FirstName is null)
AND (Email = @Email or @Email is null)
AND (Username =@Username or @Username is null)
AND (Telephone =@Telephone or @Telephone is null)

But in offline mode, it is not that simple
Any suggestions for a more efficient way ?

A:

You can use LinQ to accomplish what you want. It has similiar to you SQL-like syntax:
public List<Member> Search(string name, string email, string telephone, string username, List<Member> source)
    {
        var query = from s in source
                    where (((s.name == name) || string.IsNullOrEmpty(name))
                        && ((s.email == email) || string.IsNullOrEmpty(email))
                        && ((s.telephone == telephone) || string.IsNullOrEmpty(telephone))
                        && ((s.username == username) || string.IsNullOrEmpty(username)))
                    select s;

        return query.ToList();
    }

    public class Member
    {
        public String username;
        public String name;
        public String email;
        public String telephone;
    }

