Answer the question
In order to leave comments, you need to log in
Where is the error in the description of entities?
There are two tables, purchases and addresses. The purchase table stores the id of the address, and the addresses contain more detailed information about the address, respectively. Described each class:
[Table("ADRESSES")]
public class Adresses
{
[Key]
[Column("INDEXADRESS")]
public int ID { get; set; }
[Column("NAIMENOVANIE")]
public string NameAdress { get; set; }
public List<Zakupki> Zakupki { get; set; }
}
[Table("ZAKUPKI")]
public class Zakupki
{
[Key]
[Column("INDEXZAKUPKI")]
public int IndexZakupki { get; set; }
[Column("DATEZAKUPKI")]
public DateTime Date { get; set; }
[Column("OTKUDA")]
public int Otkuda { get; set; }
[Column("KOLICHESTVO")]
public int Kolichestvo { get; set; }
[Column("SUMMA")]
public float Summa { get; set; }
[Column("PARTIYA")]
public int PartiyaID { get; set; }
[ForeignKey("PartiyaID")]
public Partiya Partiya { get; set; }
[ForeignKey("Otkuda")]
public Adresses Adresses { get; set; }
}
dbContext.Zakupki.Adresses
the problem is that for some reason Adresses is null, like Partiya, and all other data is taken correctly. So the question is, either you can’t do it at all, or did I describe something incorrectly, or didn’t finish it?
Answer the question
In order to leave comments, you need to log in
You need to do Fetch for addresses in purchases, or configure the mapping so that this link is not a lazy load. This behavior is a feature of the Entity Framework and is configurable. Read the documentation .
I just tested lazy eagerly and explicity
using the benchmark ( homemade with Stopwatch ) and all sorts of garbage collectors,
the fastest was eagerly, it is faster than explicity
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question