EF4 LINQ Ordering Parent and all child collections with Eager Loading (.Include())

If you need to have Ordering or Filtering on inner navigation properties (e.g. Models) then you cannot eager load them using Include method anymore. Instead, you can use EntityCollection<TEntity>.CreateSourceQuery Method like this: List years = db.Years.OrderBy(“it.Name”).ToList(); foreach(year in years) { var makesQuery = year.Makes.CreateSourceQuery().OrderBy(m => m.Name); year.Makes.Attach(makesQuery); foreach(make in year.Makes) { var modelsQuery = make.Models.CreateSourceQuery().OrderBy(m … Read more

org.hibernate.LazyInitializationException at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectManyValuesForModel

While submitting, the JSF UISelectMany components need to create a brand new instance of the collection with the submitted and converted values prefilled. It won’t clear out and reuse the existing collection in the model as that may either get reflected in other references to the same collection, or may fail with an UnsupportedOperationException because … Read more

Entity Framework Core 2.0.1 Eager Loading on all nested related entities

Such feature officially does not exist currently (EF Core 2.0.2 and also the incoming 2.1). It’s been requested in Eager load all navigation properties #4851(Closed) and currently is tracked by Rule-based eager load (include) #2953 and Allow for declaring aggregates in the model (e.g. defining included properties or by some other means) #1985 (both in … Read more

EF Core returns null relations until direct access

The reason is explained in the Loading Related Data section of the EF Core documentation. The first behavior is because EF Core currently does not support lazy loading, so normally you’ll get null for navigation properties until you specifically load them via eager or explicit loading. However, the Eager loading section contains the following: Tip … Read more

How to Eager Load Associations without duplication in NHibernate?

Fetching Collections is a difficult operation. It has many side effects (as you realized, when there are fetched more collections). But even with fetching one collection, we are loading many duplicated rows. In general, for collections loading, I would suggest to use the batch processing. This will execute more SQL queries… but not so much, … Read more