2
I have the tables People and Representatives, 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, where brings representatives of People
ID PessoaID RepID
1 8 2
2 8 3
3 10 5
4 11 6
Based on this scheme I will be signing a contract where I speak of Pessoa, which I will pick up with Pessoaid and Reps through the Repid field to put in the contract if the customer has any or more than 1 reps.
I think the best way to represent this would be with String.Format(). Now assuming I have one person and she has three reporters, how would I do that in C#? I know I need to run a loop but I don’t know how to build it based on this model I need, and even more: I think I’m using too much code.
Here’s this 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 person from ID 8 and their representatives and put them in the contract
Please also enter the classes (models)
Pessoas
,Representantes
,Contrato
in the question.– MurariAlex
@Murarialex I did via Linq to SQL, I edited up part of the table as it is
– Claudinei Ferreira