1
I have the Classes:
class Procedimento
{
public string CodProcedimento { get; set; }
public string NomeProcedimento { get; set; }
public string TpSexo { get; set; }
public int IdadeMinima { get; set; }
public int IdadeMaxima { get; set; }
public string CodCbo { get; set; }
}
class RlProcedimentoRegistro
{
public string CodProcedimento { get; set; }
public string Registro { get; set; }
}
class ProcedimentoCompleto
{
public string CodProcedimento { get; set; }
public string NomeProcedimento { get; set; }
public string TpSexo { get; set; }
public int IdadeMinima { get; set; }
public int IdadeMaxima { get; set; }
public string CodCbo { get; set; }
public string Registro { get; set; }
}
I make a Join between the first two Classes to generate the third one (including the Record it property) and include it in a list:
listaProcedimentoCompleto = (from procedimento in listaProcedimento
join rlProcedimento in listaRlProcedimentoCbo on procedimento.CodProcedimento equals rlProcedimento.CodProcedimento
join rlProcedimentoRegistro in listaRlProcedimentoRegistro on procedimento.CodProcedimento equals rlProcedimentoRegistro.CodProcedimento
where rlProcedimentoRegistro.Registro.Equals("01")
orderby procedimento.NomeProcedimento
select new ProcedimentoCompleto()
{
CodProcedimento = procedimento.CodProcedimento,
IdadeMaxima = Convert.ToInt32(procedimento.IdadeMaxima / 12),
IdadeMinima = Convert.ToInt32(procedimento.IdadeMinima / 12),
NomeProcedimento = procedimento.NomeProcedimento,
TpSexo = procedimento.TpSexo,
CodCbo = rlProcedimento.CodCbo,
Registro = rlProcedimentoRegistro.Registro
}).ToList();
The idea is that: The Procedure Class has the codes of a table and the Procedural Class verifies if the record is 01, and creates the new Procedural Class.
Everything works fine so far. What I want is this:
The Procedural Classregistration DOES NOT CONTAIN all Codprocedures that exist in the Procedure Class, because there are procedures that do not have Registration, so there is no way to make the call.
As you can see in the code above, I can take all the Procedure that has the "01" Record (or other that I want), but I also want to take all that has Record "01" + those that does not contain any record, that is, those that do not exist in the table.
Let’s say I have the following
Procedimento.CodProcedimento = 1;
Procedimento.CodProcedimento = 2;
Procedimento.CodProcedimento = 3;
Procedimento.CodProcedimento = 4;
RlProcedimentoRegistro.CodProcedimento = 1, Registro = 01
RlProcedimentoRegistro.CodProcedimento = 3, Registro = 02
RlProcedimentoRegistro.CodProcedimento = 4, Registro = 01
I need to get back Procedures 1 and 4 (which has Record "01") + Procedure 2 (which is not listed in the table).
I tried to detail as much as possible, I hope you can understand well.
You just forgot to tell me what the type of each list is =D
– Jéf Bueno
The process is of the Procedure type. listaRlProcedimentRegister is of type Rlprocedural
– Italo Rodrigo
And this
listaRlProcedimentoCbo
serves no purpose (in the context of the example)?– Jéf Bueno
no. I didn’t realize she was there, but she filters the Procedure Class also by the Codcbo property. works normally too
– Italo Rodrigo