c# - Entity framework loads navigation properties without asking for them -


While working in a project, I saw a strange behavior that I can not understand with the loading properties of navigation properties.

This is a small example that repeats this "problem".

Enter image details here

My code:

I want to load one year without data of the company (navigation property) without Int id) {var reference = New Test Model Container ()) {Var result = context. // test of company = reference CompanetSet Where (C => CID == ID). FirstOver Default (); Return result; }}

It gives the year I would like, without the data in the navigation property, but if I want to delete the line and I just execute the line, probably because of its name Need to know the company or whatever, the company's figures are included in the company's navigation property of the year.

How can any idea stop this behavior? For security reasons, I want to avoid the data from 'parent'.

I am using EF 6, .NET 4.5.

The reason for this is that you are executing your orders in the same context.

In this way, if you have previously regained the year and then you retrieve the company , then the reference is already received For the unit of the year, your navigation property will be updated automatically and vice versa - the company's property will be populated in the year.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -