Assignation mal comprise
mewaketgueu
Messages postés
37
Date d'inscription
Statut
Membre
Dernière intervention
-
xROOSIE Messages postés 81 Date d'inscription Statut Membre Dernière intervention -
xROOSIE Messages postés 81 Date d'inscription Statut Membre Dernière intervention -
Salut tout le monde
svp j'ai des soucis de compréhension avec ce bout de code
wc est un string null ok
mais kan on met wc += ..... comme cela est ecrit dans mon code qu 'est ce que cela signifie?
le " LIKE @LIBELLE " je ne les comprends pas non plus
merci d'avance
voici le bout de code en bas
public class MEEntreprise : METable<Entreprise>
{
public List<Entreprise> Recherche(string Libelle)
{
string wc = null;
DataParameterCollection parameters = new DataParameterCollection();
if (!string.IsNullOrEmpty(Libelle))
{
wc += ((!string.IsNullOrEmpty(wc)) ? " AND " : null) + "((entreprise.RAISONSOCIALE LIKE @LIBELLE) OR (entreprise.NOMCOMMERCIAL LIKE @LIBELLE))";
parameters.Add(new DataParameter("@LIBELLE", string.Format("%{0}%", Libelle)));//%{0}% pour rechercher tous les enregistrement qui utilisent le caractère representé par {0}.
}
return this.ModelContext.Operator.ExecuteList<Entreprise>(new SqlStatement(string.Format("SELECT entreprise.* FROM entreprise {0}", (!string.IsNullOrEmpty(wc)) ? " WHERE " + wc : null), parameters));
}
}
public static class MEEntrepriseExtend
{
public static Entreprise Entreprise(this Intervenant Intervenant)
{
return (new MEEntreprise()).SelectionnerParId(Intervenant.IDENTREPRISE);
}
public static Entreprise Entreprise(this Materiel Materiel)
{
return (new MEEntreprise()).SelectionnerParId(Materiel.IDENTREPRISE);
}
}
svp j'ai des soucis de compréhension avec ce bout de code
wc est un string null ok
mais kan on met wc += ..... comme cela est ecrit dans mon code qu 'est ce que cela signifie?
le " LIKE @LIBELLE " je ne les comprends pas non plus
merci d'avance
voici le bout de code en bas
public class MEEntreprise : METable<Entreprise>
{
public List<Entreprise> Recherche(string Libelle)
{
string wc = null;
DataParameterCollection parameters = new DataParameterCollection();
if (!string.IsNullOrEmpty(Libelle))
{
wc += ((!string.IsNullOrEmpty(wc)) ? " AND " : null) + "((entreprise.RAISONSOCIALE LIKE @LIBELLE) OR (entreprise.NOMCOMMERCIAL LIKE @LIBELLE))";
parameters.Add(new DataParameter("@LIBELLE", string.Format("%{0}%", Libelle)));//%{0}% pour rechercher tous les enregistrement qui utilisent le caractère representé par {0}.
}
return this.ModelContext.Operator.ExecuteList<Entreprise>(new SqlStatement(string.Format("SELECT entreprise.* FROM entreprise {0}", (!string.IsNullOrEmpty(wc)) ? " WHERE " + wc : null), parameters));
}
}
public static class MEEntrepriseExtend
{
public static Entreprise Entreprise(this Intervenant Intervenant)
{
return (new MEEntreprise()).SelectionnerParId(Intervenant.IDENTREPRISE);
}
public static Entreprise Entreprise(this Materiel Materiel)
{
return (new MEEntreprise()).SelectionnerParId(Materiel.IDENTREPRISE);
}
}
1 réponse
Bonjour (je répond un peu tard) que vous mettez wc="bonjour" donc la variable est égale à bonjour
Si tu mets
string wc ="bonjour" wc=lol // la premère déclaration avec "bonjour est écrasée du coup : Console.writeLine(wc) //affiche lol
Si tu mets
string wc="bonjour" wc+="lol" Console.WriteLine(wc) //cela ne va rien écraser, ça affiche "bonjourlol"