I have the following Criteria query (using Lambda extensions):
var workflowResult = repository.GetSession()
.CreateCriteria<Core.Domain.Application>()
.SetFetchMode<Core.Domain.Application>(app => app.ApplicationWorkflows, FetchMode.Join)
.SetResultTransformer(new DistinctRootEntityResultTransformer())
.Future<Core.Domain.Application>();
This is working correctly. Each Application eagerly loads the ApplicationWorkflows collection. However, I'd like to go one deeper and load the ApplicationStatus object of each ApplicationWorkflow. I can do this with the following HQL but would like to translate to Criteria:
var workflowQuery = "SELECT DISTINCT app" +
" FROM Application app" +
" JOIN FETCH app.ApplicationWorkflows awf" +
" JOIN FETCH awf.ApplicationStatus";
I've been advised to use the following, but am having issues with it working in all cases:
.SetFetchMode<Core.Domain.Application>(app => app.ApplicationWorkflows[0].ApplicationStatus, FetchMode.Join)