5
I have two classes:
- User > Contains your PK (ID).
- User > Contains the user ID(FK).
Class User.Cs
public Usuario()
{
this.UsuariosP = new List<UsuarioP>();
}
public int Id { get; set; }
(...)
public virtual ICollection<UsuarioP> UsuariosP { get; set; }
Class Usuariop.Cs
public partial class UsuarioP
{
public int Id { get; set; }
public Nullable<int> IdUsuario{ get; set; }
public string Login { get; set; }
(...)
public virtual Usuario Usuario{ get; set; }
}
The classes were mapped like this.
I’d like to call the Login
that’s inside UsuárioP
in Usuario
. I can’t because of their relationship, otherwise I could.
Attempts - I have already created a virtual User attribute within User. (Unsuccessful) - I have tried to urge you in this way:
public string login {get { return this.UsuarioP.Login} } (Sem sucesso)
- Putting
Login
inUsuario.cs
as[NotMapped]
(Unsuccessful)
Important: I want to do the get and set of this attribute. My project is working with controllers, services, models and views.
How to call the Login
inside UsuarioP
, so I can use it on the User screens?
Note: Working with MVC 4
EPH 5
Fluent API
I should use a template inside the login attribute. This way you made the 1) .. I could put the template?
– O Aprendiz
Yes, but that’s another question. You can do and paste the link here and I’ll answer it for you.
– Leonel Sanches da Silva
I asked a question yesterday about that.. assuming that the initial idea was how to get this attribute, I did not get help: pq actually what I really need is this (I am totally lost) :http://answall.com/questions/89318/met%C3%B3do-include-mvc-working-with-inser%C3%A7%C3%A3o-of-data-in-two-tables
– O Aprendiz
I wanted to use the get of this attribute and make sure that at the time of inserting on the include screen it gets the value for the other table...
– O Aprendiz