Filter data with optional parameters I would make a filter to filter my data using next parameters: 


First name
Last name
Language
Profile
A minimum date of registration
A maximum date of registration
Success


All filter options are not required for the user. Here could you find my C# code.

private IEnumerable&lt;Registration&gt; Filter(string voornaam,   // first name
                                         string achternaam, // last name
                                         int? language, 
                                         int? profiel,      // profile
                                         DateTime? vanaf,   // min date
                                         DateTime? tot,     // max date
                                         bool? geslaagd)    // success
{
    IEnumerable&lt;Registration&gt; all = All(); // &lt;-- this gets all registrations from 
                                           //       the database.

    if (!string.IsNullOrEmpty(voornaam))
    {
        all = (from r in all
               where r.FirstName.ToLower().StartsWith(voornaam.ToLower().Trim())
               select r).ToList();
    }

    if (!string.IsNullOrEmpty(achternaam))
    {
        all = (from r in all
               where r.LastName.ToLower().StartsWith(achternaam.ToLower().Trim())
               select r).ToList();
    }

    if (language != null)
    {
        all = (from r in all
               where r.LanguageId == language.Value
               select r).ToList();
    }

    if (profiel != null)
    {
        all = (from r in all
               where r.ProfileId == profiel.Value
               select r).ToList();
    }

    if (vanaf != null)
    {
        all = (from r in all
               where r.RegistrationDate &gt;= vanaf.Value
               select r).ToList();
    }

    if (tot != null)
    {
        all = (from r in all
               where r.RegistrationDate &lt;= tot.Value
               select r).ToList();
    }

    if (geslaagd != null)
    {
        all = (from r in all
               where r.Success == geslaagd.Value
               select r).ToList();
    }

    return all;
}


The function All() gets all the registrations from the database. Next I check if the attributes are not null (or empty for the strings) and if true I set the variable all equal to the return values of the linq query's. After all I return all and load my view.

This code works for all possibilities and got a low fail percentage. Of course my code is too long and will make this code shorter. How could I do this?
IEnumerable&lt;Registration&gt; all = All(); // &lt;-- this gets all registrations from 
                                       //       the database.



This looks like a really bad idea. Why are you getting all data from the database first and not filter it before retrieving? 


where r.FirstName.ToLower().StartsWith(voornaam.ToLower().Trim())



Most databases are case insensitive so you wouldn't need this formatting adjustment if you used server side filtering. 

On the client it's better to use the StrigComparer.XIgnoreCase where the X is either the InvariantCulture or Ordinal then ToUpper/Lower because on the one hand it better communicates the intention that you are performing a case-insensitive comparison (which is not that obvious if you use ToUpper/Lower - you might be just fixing the case for whatever reason) and on the other hand you don't have to change the case twice which might introduce a new bug if you call ToUpper for the first string and ToLower for the other one or forget it altogether.

If you use EF or any other ORM you should filter the data on the server and not after downloading everything. With large databases this would be such a waste of resources.

If All is backed by Entity Framework then you could return an IQueryable and still take the advantange of a server query.

Why don't you use english variables names? Everything is in english but the parameters. This is not consistant... and it's difficult to get help with local names.