0
I’m trying to make the relationship between two classes "Tables".
I am mounting an API for MVC5 EF6 in Visual Studio however I need information from one class to appear in the other.
public class ASSOCIADO
{
public string ID_EMPRESA { get; set; }
*public ICollection<EMPRESA> NM_FANTASIA_EMPRESA { get; set; }
[Key]
public string ID_ASSOCIADO { get; set; }
public string NM_ASSOCIADO { get; set; }
public string NR_CPF { get; set; }
public string DS_EMAIL { get; set; }
public DateTime? DT_NASCIMENTO { get; set; }
public DateTime? DT_INATIVACAO { get; set; }
*public virtual EMPRESA NM_FANSTASIA_EMPRESA { get; set; }
}
In this code above, I have the member information and I have CD_EMPRESA (KEY in Company Class), the codes with * were some attempts found on the internet to bring these values.
In another Class I have this code:
public class EMPRESA
{
[Key]
public string ID_EMPRESA { get; set; }
public string NM_FANTASIA_EMPRESA { get; set; }
}
I need to present the NM_FANTASIA_EMPRESA in the ASSOCIATED class, so that according to its ID_EMPRESA.
an associate has 1 or several companies ? if 1, uses the code below, if not, the code above. Can remove
public string ID_EMPRESA { get; set; }
of the associate also– Rovann Linhalis
@Rovannlinhalis he has only 1 company.
– Eduardo Grangeiro
@Rovannlinhalis I made the change and searched the value I wanted, thank you!
– Eduardo Grangeiro