Entity Framework with Proxy Creation and Lazy Loading disabled is still loading child objects -


i'm having issues entity framework using pocos , hope can tell me @ high level if behaviour i'm seeing expected or need dig deeper why it's happening.

i have class customer , customertype, customer has property type (of type customertype indicating type) , customertype has property customers collection of customers (all customers have type) these navigation properties on both ends of association, resulting in poco code like:

public partial class customer {     public int id { get; set; }     public string name { get; set; }     public int typeid { get; set; }     public customertype type { get; set; } }  public partial class customertype {     public customertype()     {         this.customers = new hashset<customertype>();     }      public int id { get; set; }     public string typename { get; set; }      public virtual icollection<customer> customers { get; set; } } 

i have turned off proxy creation , lazyloading (i.e. both dbcontext.configuration.proxycreationenabled=false , dbcontext.configuration.lazyloadingenabled=false) because make serialization pain.

as expected when instances customer set, type property on them null default.

but if instances customer set .include("type") not loading type properties, it's loading children - i.e. collection of customers on each of these.

is expected?

it semi expected. include extension affects sql run. customertypes loaded (by virtue of being included in customer query) built object tree according customertype.parentid column.

so if fluke both parent , child loaded in same query, child stuffed parent.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -