I want my application to work without lazy load by default. However in some cases (which I want to set explicitly) I need lazy loading.
So, my default conventions are (last line swithes off default lazy loading):
Fluently.Configure().Database(driverConfig)
.Mappings(m => m
.FluentMappings.AddFromAssemblyOf<Limit>()
.Conventions.AddFromAssemblyOf<Limit>()
.Conventions.Add(PrimaryKey.Name.Is(x => x.EntityType.Name + "Id"))
.Conventions.Add(DefaultCascade.All())
.Conventions.Add(ForeignKey.EndsWith("Id"))
.Conventions.Add(ConventionBuilder.Id.Always(x => x.GeneratedBy.Native()))
.Conventions.Add(ConventionBuilder.Id.Always(x => x.Unique()))
.Conventions.Add(Cache.Is(x => x.NonStrictReadWrite()))
.Conventions.Add(DefaultLazy.Never())
And I want this Many relation to be lazy loaded:
HasMany(x => x.TestCaseOrdered).KeyColumn("ProductVariantId").LazyLoad();
However, it isn’t lazy loaded. I tried to replace DefaultLazy.Never() convention with LazyLoad.Never() but it doesn’t work (and I cannot understand the difference).
How can I easily switch off lazy loading for all cases except one concrete?
I was retrieving tests with code:
That was the problem