Bonjour,

La méthode "RUN_SQL_EXTRACT" ci dessous renvoie une liste ( "Return RCD_INTERLO_COLLEC" ).


Mon souci, c'est que j'appelle cette méthode dans une autre classe d'une autre programme et je souhaite récupérer dans la méthode appelante ma liste <>.


J'ai bien essayé le code suivant :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// [ Bouton test Extraction INTERLOCUTEUR ]
        private void BTN_TST_ASSEMBLY_REQTE_INTERLO_Click(object sender, RoutedEventArgs e)
        {
 
            // Instancie la classe de la méthode à appeler 
            INTERLO_CLASS_DLL.CLS_LIST_INTERLO RQTE_INTERLO = new INTERLO_CLASS_DLL.CLS_LIST_INTERLO();
 
            // Crée un objet liste "LISTE_INTERLO"  ayant la même structure que l'objet List renvoyé par la méthode "RUN_SQL_EXTRACT"
            List<CLS_STR_INTERLO> LISTE_INTERLO = new List<CLS_STR_INTERLO>();
 
            // Appelle la méthode "RUN_SQL_EXTRACT" ( avec les bons paramètres ) et récupère la liste "CLS_STR_INTERLO" dans "LISTE_INTERLO "
            LISTE_INTERLO = RQTE_INTERLO.RUN_SQL_EXTRACT("ARC", "PIERRE");
 
        }


Le compilateur me renvoie l'erreur :
"Impossible de convertit implicitement le type "system.Collectios.Generic.List<INTERLO_CLASS_DLL.STRINTERLO>' en system.Collecdtions.Generic.List<VCNET_START_ASSEMBLY_PGM.CLS_STR_INTERLO>".



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
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
public List<CLS_STR_INTERLO>RUN_SQL_EXTRACT(string P_FCTN, string P_ARGUMENT_EXTRACT_REQUETE)
        {
 
            // [ on construit la requête à partir des mots
            //  saisis dans la zone de recherche ] 
            String W_ResulSql = CLS_STQ_BUILD_RQTE_INTERLO.RQTE_INTERLO(P_FCTN, P_ARGUMENT_EXTRACT_REQUETE);
 
            // [ Création de la connection ]
            String ConnectString = "Provider=IBMDA400;" +
                                        "Password=WEBDEV;" +
                                        "User ID=WEBDEV;" +
                                        "Data Source=192.168.1.192;";
 
            OleDbConnection ConnectLst = new OleDbConnection(ConnectString);
 
            try
            {
 
                ConnectLst.Open();
            }
            catch (Exception ex)
            {
                // ( Gérer traitement erreur ici ) 
            }
 
            // [  Création adaptateur  ]
            OleDbDataAdapter MyAdapt = new OleDbDataAdapter();
 
            // [ Création DataSet ]
            DataSet myDataSet = new DataSet();
 
 
            // Exécution de la requête via l'adapteur et injection dans le DataSet
            // [ Un ADAPTATEUR sert à REMPLIR un DATASET ]
            // ( L'adapteur lance et exécute la requête en ouvrant la connexion ) 
            MyAdapt.SelectCommand = new OleDbCommand(W_ResulSql, ConnectLst);
 
            try
            {
                MyAdapt.Fill(myDataSet, "INTERLO");
            }
            catch (Exception ex)
            {
               // ( Gérer traitement erreur ici ) 
            }
 
            // [ Création d'une collection de la structure  RCD_INTERLO ]
            //   ( On crée une collection "RCD_INTERLO_COLLEC" 
            //     à partir de la structure "RCD_INTERLO" ) 
            List<CLS_STR_INTERLO> RCD_INTERLO_COLLEC = new List<CLS_STR_INTERLO>();
 
 
            // [ Chargement de la collection en alimentant la structure ] 
            //  ( Pour chaque ligne de la table "INTERLO" du dataset "MyDatSet", 
            //    on alimente ligne par ligne la collection "RCD_INTERLO_COLLEC" ) 
            foreach (DataRow row in myDataSet.Tables["INTERLO"].Rows)
            {
                RCD_INTERLO_COLLEC.Add(new CLS_STR_INTERLO()
                {
                    NOM = (row["FNOMIN"].ToString()),
                    PRENOM = (row["FPREIN"].ToString()),
                    RESPONSABLE = (row["FNMRSP"].ToString()),
                    TITRE = (row["FTITRE"].ToString()),
                    LIBELLE_TITRE = (row["FTITLL"].ToString()),
                    FONCTION = (row["FFONCT"].ToString()),
                    LIBELLE_FONCTION = (row["FFONLL"].ToString()),
                    SERVICE = (row["FSERVA"].ToString()),
                    LIBELLE_SERVICE = (row["FSERLL"].ToString()),
                    USER = (row["FUSER"].ToString()),
                    SOCIETE = (row["FSTE"].ToString()),
                    ETAB = (row["FETAB"].ToString()),
                    NUM_CHRO = (row["FCHROI"].ToString())
                });
            }
 
            return RCD_INTERLO_COLLEC;
 
        }
    }

J.C