LLBLGen Pro Version: 1.0.2005.1 Final
Database: SQL 2005
My question concerns preforming multiple prefetch steps when retrieving a collection from the database. Allow me to explain:
ApplicationEntity relates to EmployeeEntity, so I can prefect the Employee of the Application and later access the employee via ApplicationEntity.Employee.
SSNEntity relates to the EmployeeEntity, so if prefetch is preformed, i can do EmployeeEntity.SSN to access the SSN attributes of this employee.
IS there any way i can execute two prefetchs, so taht when i retrieve my ApplicationEntity collection, the related employee will already have the
related SSN entity retrieved?
The code i have to retrieve the application entities with employees prefetched is below:
IPrefetchPath2 prefetchPath = new PrefetchPath2((int)EntityType.ApplicationEntity);
prefetchPath.Add(ApplicationEntity.PrefetchPathEmployee);
EntityCollection applicationCol = new EntityCollection(new ApplicationEntityFactory());
RelationPredicateBucket filter = new RelationPredicateBucket();
filter.Relations.Add(ApplicationEntity.Relations.EmployeeMasterEntityUsingEmpId);
filter.PredicateExpression.Add(PredicateFactory.Like(EmployeeMasterFieldIndex.FirstName, pmEmployeeFName + "%"));
filter.PredicateExpression.Add(PredicateFactory.Like(EmployeeMasterFieldIndex.LastName, pmEmployeeLName + "%"));
filter.PredicateExpression.Add((ApplicationFields.TsFinish != System.DBNull.Value));
filter.PredicateExpression.Add((ApplicationFields.TsInterviewFinish == System.DBNull.Value));
DataAccessAdapter da = new DataAccessAdapter();
da.FetchEntityCollection(applicationCol, filter, prefetchPath);
Thanks in advance!
Adam