I have the following template:
public class Usuario
{
public int idUsuario { get; set; }
public string Nome { get; set; }
public string Email { get; set; }
public string Senha { get; set; }
public int Permissao { get; set; }
public List<Evento> Eventos { get; set; }
}
In the database it is many-to-many, ie User - thirdtable - Events.
In my User Application layer I have persistence, and I have a specific ListAll method that does the select of users and calls the TransformaReaderEmListSource () method.
private List<Usuario> TransformaReaderEmListadeObjeto(MySqlDataReader reader)
{
var usuarios = new List<Usuario>();
while (reader.Read())
{
var temObjeto = new Usuario()
{
idUsuario = int.Parse(reader["idUsuario"].ToString()),
Email = reader["email"].ToString(),
Senha = reader["senha"].ToString(),
Permissao = Convert.ToInt32(reader["permissao"].ToString())
};
usuarios.Add(temObjeto);
}
reader.Close();
return usuarios;
}
Okay, so far, no problem. I want to list the events related to the user, that is, I need to also list the user events in the third table. So I need the User template to know the events it belongs to. Okay.That is, by logic, correct me if I am wrong, I also need a ListAllEvents () method. However, if I create another Reader Transformer in List, I will be listing only events that belong to a user of Id: x;
So I need to concatenate this list I created from users so that each user has their list of events. fodeu
Can anyone give me the stones path to solve this problem? Or, clarify me.