How to pass a string value to a type in the Entity

Asked

Viewed 55 times

1

In my Entity mapping, the fields that are FK got like this:

public virtual T_Acao T_Acao { get; set; }
public virtual ICollection<T_OsParceiro> T_OsParceiro { get; set; }
public virtual T_ProximaAcao T_ProximaAcao { get; set; }

In my program I need to pass a string value to T_acao. How do I do this? I tried a cast like this, but I couldn’t:

tarefa.T_Acao = osParceiro.AcaoParceiro;

AcaoParceiro is the type string. I tried a cast that way:

tarefa.T_Acao = (SuporteTecnico.Models.T_Acao)osParceiro.AcaoParceiro;

The mistake is:

Cannot implicity Convert type "string" to SuporteTecnico.Models.T_Acao

  • The mistake is clear. You are trying to use a string to assign to an object. I don’t understand why you need to necessarily pass a string.

  • is that it comes like this

  • So ask me the question of all models, please: T_Acao, T_OsParceiro, T_ProximaAcao.

1 answer

2

I killed with a colleague’s jewel. I did so:

T_Acao t = new T_Acao();
t.acao = osParceiro.Acao;
tarefa.T_Acao = t;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.