how to declare a list of object nullable asp .net

asp.net asp.net-mvc c# entity-framework-6 visual-studio

Question

Good Morning , I'm a beginner in asp .net Acually I prepare the database using the first code approach And my question is: How to declare a list of objects that can be null ?

enter image description here

1
-4
7/19/2017 1:32:20 PM

Accepted Answer

Looking at your diagram, I'm guessing what you meant is that your Employer object may have 0 or more BonDeCommande object. As such List<BonDeCommande> is what you want (which may have an empty list -- rather than null)

public class Employer {
    public string code {get; set;}
    public string mdp {get; set;}
    ...
    public List<BonDeCommande> bonDeCommandes {get; set;}
}
2
7/19/2017 12:12:05 PM

Popular Answer

List<int?> aList = new List<int?>();

The question mark means that the value can be null



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow