I am creating an application in which you can make reservations, in the mapper of the properties I have passed a method called "LoadProperties" in which I pass the data such as type, etc, the problem is when you I want to pass the user who has registered that property, I did it in the following way:
private Propiedad CargarPropiedad (SqlDataReader r)
{
var prop= new Propiedad();
prop.idPropiedad = Convert.ToInt32(r["idPropiedad"]);
//prop.usuario = new Usuario() { idUsuario = Convert.ToInt32(r["idUsuario"])};
...
...
}
In the form when creating a property, what I do is make a session variable
Usuario user = (Usuario)Session["Usuario"];
Propiedad prop = new Propiedad()
{
usuario = user,
nombre = txtNombre.Text,
...
...
...
}
If anyone could help me, I would be very grateful, greetings.