Current filter:
                                You should refresh the page.
                                  • In certain scenario I would need to prefetch collections using Session.PreFetch, however this collections are available using upcasting only, like this:

                                    [C#]
                                    using (UnitOfWork uow = BaseDataLayerFactory.CreateUnitOfWork()) { var responsibilities = new XPQuery<ResponsibilityProvider>(uow).ToArray(); uow.PreFetch(responsibilities, "<PersonGroupResponsibilityProvider>PersonGroup.Persons"); }

                                    However it results in PropertyMissingException. Is it right approach? Does Session.PreFetch support upcasting at all? How to proceed?

                                    Thanks a lot for you advice.

                                1 Solution

                                Creation Date Importance Sort by

                                Hello Svatopluk,

                                Although the Prefetch method does not support upcasting, you can achieve the required result. To do this, use the Enumerable.OfType extension method to extract PersonGroupResponsibilityProvider objects and pre-fetch their collections.

                                [C#]
                                var personGroupResponsibilities = responsibilities.OfType<PersonGroupResponsibilityProvider>(); uow.PreFetch(personGroupResponsibilities, "PersonGroup.Persons");
                                • Svatopluk Ulicny 10.03.2019

                                  Thanks a lot for your advice.