I spent the last two days trying to debug an InvalidCastException error that was generated because I prefetched to an ancester:
IPrefetchPath2 prefetchPath = new PrefetchPath2((int)EntityType.AccountEntity) ;
prefetchPath.Add(AccountEntity.PrefetchPathManagerContact) ;
/* NOTE! Above line SHOULD be: "prefetchPath.Add(Account).PrefetchManagerContact". AccountEntity is an ancester of Account. This code compiles but generates an InvalidCastExpection that is VERY difficult to debug!!! */
ent = new Account (key) ;
DataAccessAdapter adapter = new DataAccessAdapter();
adapter.FetchEntity(ent, prefetchPath) ;
... elsewhere...
... MessageBox.Show ("Contact name is: " + (Account)accountEntity).ManagerContact.ContactName) // OOPS! InvalidCastException at runtime!!
Anyway, this is a heads-up to all you good LLBLGenPro coders.
Happy New Year.
Jeff