Salut,

Je suis en train d'écrire une application en .NET 3.5, et j'ai besoin de vos lumières concernant la transformation d'un code que j'utilisais en ADO.NET vers son équivalent LINQ To SQL.

Voici ce que je faisais en C# 2.0 :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public IList<Client> GetList(string nom, string prenom)
{
    SqlCommand command = /* Toutes les étapes d'initialisation */
 
    if (!String.IsNullOrEmpty(nom))
    {
        command.CommandText += " AND NOM = @nom";
        command.Parameters.Add(/* Le paramètre qui va bien */);
    }
 
    if (!String.IsNullOrEmpty(prenom))
    {
        command.CommandText += " AND PRENOM = @prenom";
        command.Parameters.Add(/* Le paramètre qui va bien */);
    }
 
    // Execution et retour
}
Ma question est : "comment ajouter les Where clauses dynamiquement avec LINQ To SQL ?"