bonjour à tous,

je débute dans le MVVM, voici mon problème , j'ai une vue qui va afficher des données de plusieurs tables : applications et versions ou une application peut avoir plusieurs versions (donc plusieurs models).

voici mon code :

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
 
public partial class ApplicationARV
    {
        public ApplicationARV()
        {
            Logs = new HashSet<Log>();
            Versions = new HashSet<VersionApps>();
        }
 
        public int IdApplication { get; set; }
        public int KeyLicence { get; set; }
        public string CodeName { get; set; }
        public string DisplayName { get; set; }
        public bool? Internal { get; set; }
 
 
        public virtual Licence KeyLicenceNavigation { get; set; }
        public virtual ICollection<Log> Logs { get; set; }
        public virtual ICollection<VersionApps> Versions { get; set; }
    }
 
public class VersionApps
    {
        protected static object Version_Available;
 
        public static object Version_Installed { get; protected set; }
        public int IdVersion { get; set; }
        public string VersionNumber { get; set; }
        public string PatchNotes { get; set; }
        public string ImageId { get; set; }
        public string ContainerId { get; set; }
        public string ContainerParam { get; set; }
        public string VersionDownloaded { get; set; }
        public string VersionAvailable { get; set; }
        public int? IdApplication { get; set; }
 
        public virtual ApplicationARV IdApplicationNavigation { get; set; }
    }
et mon fichier ViewModel qui va alimenter ma vue.
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
 
public ApplicationARVViewModel()
        {
 
            LoadApplication();
        }
        public List<Models.ApplicationARV> LoadApplication()
 
        {
            AVSContext _context = new AVSContext();
 
            List<Models.ApplicationARV> ListAppli = new List<Models.ApplicationARV>();
 
            foreach (var appli in _context.Applications.Include(x => x.Versions).Include(x => x.KeyLicenceNavigation).ToList()) 
            {
 
                ListAppli.Add(appli);
            }
            return ListAppli;
        }
 
 
    }
mon resultat me retourne une liste d'applicationARV (mon model); mais si je veux récupérer mes versions comment je fais ? car appli.Version[0].NumberVersion ne fonctionne pas,

en espérant avoir été claire.

merci de votre aide..