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 (including the Record property to it) 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 Class Procedure has the codes of a table and the Class RlProcedureRegister checks to see if the record is equal to 01, and creates the new Class ProcedureComplete.
It works fine here. What I want is the following:
The Class RlProcedureRegistration DOES NOT CONTAIN all the CodProcedimentos that exist in the Procedure Class, because there are procedures that have no registry, so you can not make the connection.
As you can see in the code above, I can get all the Procedure that has the "01" Registry (or another one I want), but I also want to get all that has "01" Registry + those that do not contain any registry , that is, those that do not exist in the RlProcedureRegistration 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 return Procedures 1 and 4 (which has Registration "01") + Procedure 2 (not listed in the RlProcedureRegistration table).
I tried to detail as much as possible, I hope you can understand.