I would like to know if the following scenario is possible with Entity Framework:
I want to load several tables using the AsNoTracking option, because they are all like static tables that the user cannot modify.
These tables are also navigational properties of others. So far, I have relied on the AutoMapping function in the Entity Framework and have not used the .Include () or LazyLoading functions.
So, instead of:
var result = from x in context.TestTable .Include("ChildTestTable") select x;
I use it as follows:
context.ChildTestTable.Load(); context.TestTable.Load(); var result = context.TestTable.Local;
This works smoothly because the application is designed in such a way that the tables in the database are very small, there will not be a table that exceeds 600 rows (and this is already quite an expensive value in my application).
Now my way of loading data does not work with .AsNoTracking (). Is there any way to make it work?
Therefore, I can write:
context.ChildTestTable.AsNoTracking().List(); var result = context.TestTable.AsNoTracking().List();
Instead:
var result = from x in context.TestTable.AsNoTracking() .Include("ChildTestTable") select x;
So, basically, I want to have one or more tables loaded by the AutoMapping function, but not loading them into the Object State Manager, is this an opportunity?
c # entity-framework
Rand random
source share