I have the following model:
public sealed class Consignor : TwoNames
{
public Consignor()
{
Address = new Address();
}
}
It's mother class TwoNames looks like this:
public abstract class TwoNames : Search
{
[Required]
public int AddressId { get; set; }
public virtual Address Address { get; set; }
[Required]
public string Name1 { get; set; }
public string Name2 { get; set; }
}
And my Address model is here:
public class Address : Model
{
[Required]
public string Street { get; set; }
[Required]
public string ZipCode { get; set; }
[Required]
public string City { get; set; }
public string Country { get; set; }
public string Email { get; set; }
}
They all inherit from "Model". Model has just an id. Everything works well, BUT: Lazy loading seems to be not working.
I'm loading a consignor like this:
List<Consignor> consignors = UnitOfWork.ConsignorRepository.Get().ToList();
All of the consignors got the correct AddressID and Address is not null (I guess because of my constructor in the Consignor class) but the Address property is not filled correctly (no street, no zip code, etc.).