Hello. There are 2 tables in the database. And they have a many-to-many connection with each other. Users and profiles. Here are their classes:

class Users { public int Id { get; set; } public string Surname { get; set; } public string Name { get; set; } public string Patronimyc { get; set; } public string Login { get; set; } public string Password { get; set; } public virtual ICollection<Questionnaires> Questionnaires { get; set; } public Users() { Questionnaires = new List<Questionnaires>(); } } class Questionnaires { public int Id { get; set; } public string Name { get; set; } public int SubjectsId { get; set; } public virtual Subjects Subjects { get; set; } public virtual ICollection<Questions> Questions { get; set; } public virtual ICollection<Users> Users { get; set; } public Questionnaires() { Users = new List<Users>(); } } 

On the form there is a grid. I upload questionnaires to it using lazy loading:

 Context db; public Form3() { InitializeComponent(); db = new Context(); db.Questionnaires.Load(); db.Users.Load(); dataGridView1.DataSource = db.Questionnaires.Local.ToBindingList(); } 

During the migration of these tables, another 1 was created. The third table for communication, where the user’s ID and the questionnaire ID are. Filled this table by itself. I also upload users, because I need to select all the questionnaires for a specific user and vice versa, all users who have passed a specific questionnaire. But when I look at the debugging in the code, I see that the users do not drag behind the questionnaires, that is, the user collection is empty. Why it happens? After all, I specifically indicated that users also need to pull up. Please tell me what I'm doing wrong.

  • We will be precise in terminology: using the Load method is just not a lazy load. - Alexander Petrov
  • @AlexanderPetrov thanks, really helped in the question ... - Andrew

0