I'm using Fluent NHibernate in order to auto map my entities.
This is the code I'm using for the auto mapping:
new AutoPersistenceModel()
.AddEntityAssembly(Assembly.GetAssembly(typeof(Entity)))
.Where(type => type.Namespace.Contains("Domain") && type.BaseType != null && type.BaseType.Name.StartsWith("DomainEntity") && type.BaseType.IsGenericType == true)
.WithSetup(s => s.IsBaseType = (type => type.Name.StartsWith("DomainEntity") && type.IsGenericType == true))
.ConventionDiscovery.Add(
ConventionBuilder.Id.Always(x => x.GeneratedBy.Increment())
);
This works just fine. But now I need to have Eager Loading in one single object of my domain. Found this answer. But when I add the line .ForTypesThatDeriveFrom<IEagerLoading>(map => map.Not.LazyLoad())
to the code and run it I get the following exception:
- Error while trying to build the Mapping Document for IEagerLoading
Notice that I'm using an interface (IEagerLoading
) to mark the objects that I want eager load.
Can anyone help how to do this? Remember that I want to keep the auto mapping functionality.
Thanks