I have the People and Representatives tables, where in my application the person may or may not have representative (s).
public class Conta
{
int PessoaID;
string Nome;
String Documento;
}
public class Representante
{
int RepresentanteID;
int PessoaID.
string Nome;
String Documento;
}
Based on this I have a third table, which brings People's Representatives
ID PessoaID RepID
1 8 2
2 8 3
3 10 5
4 11 6
Based on this scheme, I generate a contract where I tell the Person that I will pick up with the PersonID and the Representatives from the RepID field to place in the contract if the client has one or more representatives.
I think the best way to represent this would be with String.Format (). Now assuming I have one person and she has 3 reprenters, how would I do it in C #? I know I need to run a loop but I do not know how to mount it based on that model I need, and more: I think I'm using too much code.
Here's part of what I did:
var pessoa = (from p in db.Pessoas
where pPessoaID == pessoaid
select p).SingleOrDefault();
var representante = (from p in db.Representantes
where p.RepID == repid
select p).SingleOrDefault();
var contrato = from p in db.Contrato
where p.PessoaID == pessoa.PessoaID
select p;
The question is: How do I get the ID 8 person and their representatives and put them on the contract