Lazy Load only loads data when Solution remains

Asked

Viewed 31 times

0

Guys, I have the following problem: When I make the Entity Framework add a data in the database, it does, but does not return the attributes of the loaded Class type. In order for them to load normally, I need to reestablish the Solution.

My mapping is correct... My entity is as Virtual and the mapping of the class and DTO is correct.

Somebody’s got a tip on what to do?

  • Submit your code

  • "but does not return loaded class attributes to me" What does that mean, exactly?

1 answer

0

I know two important settings when it comes to Lazy Load and that have helped me over time:

1) Reiterate in context setting:

Example:

   contexto.Configuration.LazyLoadingEnabled = false;

2) When the class has relationships, you must include them [.Include(x => x.{COLLECTION})]:

Example:

   var produtos = _contexto.Produtos
                           .Where(p => p.Name == "Camisa")
                           .Include(x => x.Cores)
                           .ToList();

I hope it helps.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.