You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I have a folder inside a document library in SharePoint, and enumerate the child objects (files or folders) of that folder, using .AsRequested(), it returns objects of the root folder, not the specified folder.
I have a SharePoint document library named "SDK Test" with the following structure:
If I enumerate the Files or Folders on the document library (using the RootFolder as shown in documentation), it works correctly and returns the same results whether or not I include the .AsRequested().
However if I get a reference to the document folder ("Top-level Folder") and enumerate its children, I get different results if I use .AsRequested(): it shows the top-level files/folders.
The comments on AsRequested() indicate it simply uses previously-loaded data to prevent another round-trip to SharePoint:
// We're using AsRequested() to query the already loaded domain models, if not a new query would // issued to load the lists
As such I can see that .AsRequested may have the capability to return cached data if called first, but:
I'm calling .Files directly before calling .AsRequested()
It's returning data from the parent document library, not the specified folder.
Also the order of calling .Files or .Files.AsRequested() doesn't matter.
Steps to reproduce
This code can be used to replicate the issue:
publicasyncTaskTestSdk(){usingPnPContextcontext=_pnpContextFactory.Create("Default");IFolderlibraryFolder=(awaitcontext.Web.Lists.GetByTitleAsync("SDK Test", p =>p.RootFolder)).RootFolder;awaitlibraryFolder.LoadAsync(p =>p.Folders, p =>p.Files);Console.WriteLine("Library Folder");Console.WriteLine("--------------");PrintDebug(libraryFolder);Console.WriteLine();IFoldertopLevelFolder=libraryFolder.Folders.FirstOrDefault(p =>p.Name=="Top-level Folder")!;awaittopLevelFolder.LoadAsync(p =>p.Folders, p =>p.Files);Console.WriteLine("Top-level Folder");Console.WriteLine("----------------");PrintDebug(topLevelFolder);}publicvoidPrintDebug(IFolderfolder){foreach(varfinfolder.Folders){Console.WriteLine($"Folders: {f.Name}");}foreach(varfinfolder.Folders.AsRequested()){Console.WriteLine($"Folders AsRequested: {f.Name}");}foreach(varfinfolder.Files){Console.WriteLine($"Files: {f.Name}");}foreach(varfinfolder.Files.AsRequested()){Console.WriteLine($"Files AsRequested: {f.Name}");}}
AsRequested() can return cached or old for the specified folder ("Top-level folder"), but it should not be returning data for the library ("SDK Test").
Category
Describe the bug
If I have a folder inside a document library in SharePoint, and enumerate the child objects (files or folders) of that folder, using
.AsRequested()
, it returns objects of the root folder, not the specified folder.I have a SharePoint document library named "SDK Test" with the following structure:
If I enumerate the Files or Folders on the document library (using the RootFolder as shown in documentation), it works correctly and returns the same results whether or not I include the
.AsRequested()
.However if I get a reference to the document folder ("Top-level Folder") and enumerate its children, I get different results if I use
.AsRequested()
: it shows the top-level files/folders.The comments on
AsRequested()
indicate it simply uses previously-loaded data to prevent another round-trip to SharePoint:As such I can see that
.AsRequested
may have the capability to return cached data if called first, but:.Files
directly before calling.AsRequested()
Also the order of calling
.Files
or.Files.AsRequested()
doesn't matter.Steps to reproduce
This code can be used to replicate the issue:
And this is the output:
Expected behavior
AsRequested()
can return cached or old for the specified folder ("Top-level folder"), but it should not be returning data for the library ("SDK Test").Environment details (development & target environment)
The text was updated successfully, but these errors were encountered: